Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Correct misc-misplaced-widening-cast clang warnings #435

Merged
merged 2 commits into from
Nov 2, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,6 @@ if (${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} GREATER 3.5) # Need 3.6 or abo
",-google-readability-todo"
",-google-runtime-int"
",-google-runtime-references"
",-misc-misplaced-widening-cast"
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why disable the check?

Copy link
Contributor Author

@benrubson benrubson Oct 29, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All checks are enabled, but the listed ones.
So this change re-enables the check which was previously disabled 👍

",-misc-unused-parameters"
",-modernize-loop-convert"
",-readability-inconsistent-declaration-parameter-name"
Expand Down
2 changes: 1 addition & 1 deletion encfs/BlockFileIO.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ ssize_t BlockFileIO::write(const IORequest &req) {
unsigned char *inPtr = req.data;
while (size != 0u) {
blockReq.offset = blockNum * _blockSize;
int toCopy = min((size_t)(_blockSize - partialOffset), size);
size_t toCopy = min((size_t)_blockSize - (size_t)partialOffset, size);

// if writing an entire block, or writing a partial block that requires
// no merging with existing data..
Expand Down
14 changes: 7 additions & 7 deletions encfs/SSL_Cipher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -301,11 +301,11 @@ SSLKey::SSLKey(int keySize_, int ivLength_) {
this->ivLength = ivLength_;
pthread_mutex_init(&mutex, nullptr);
buffer = (unsigned char *)OPENSSL_malloc(keySize + ivLength);
memset(buffer, 0, keySize + ivLength);
memset(buffer, 0, (size_t)keySize + (size_t)ivLength);

// most likely fails unless we're running as root, or a user-page-lock
// kernel patch is applied..
mlock(buffer, keySize + ivLength);
mlock(buffer, (size_t)keySize + (size_t)ivLength);

block_enc = EVP_CIPHER_CTX_new();
EVP_CIPHER_CTX_init(block_enc);
Expand All @@ -320,10 +320,10 @@ SSLKey::SSLKey(int keySize_, int ivLength_) {
}

SSLKey::~SSLKey() {
memset(buffer, 0, keySize + ivLength);
memset(buffer, 0, (size_t)keySize + (size_t)ivLength);

OPENSSL_free(buffer);
munlock(buffer, keySize + ivLength);
munlock(buffer, (size_t)keySize + (size_t)ivLength);

keySize = 0;
ivLength = 0;
Expand Down Expand Up @@ -593,7 +593,7 @@ CipherKey SSL_Cipher::readKey(const unsigned char *data,
checksum = (checksum << 8) | (unsigned int)data[i];
}

memcpy(tmpBuf, data + KEY_CHECKSUM_BYTES, _keySize + _ivLength);
memcpy(tmpBuf, data + KEY_CHECKSUM_BYTES, (size_t)_keySize + (size_t)_ivLength);
streamDecode(tmpBuf, _keySize + _ivLength, checksum, masterKey);

// check for success
Expand All @@ -608,7 +608,7 @@ CipherKey SSL_Cipher::readKey(const unsigned char *data,

std::shared_ptr<SSLKey> key(new SSLKey(_keySize, _ivLength));

memcpy(key->buffer, tmpBuf, _keySize + _ivLength);
memcpy(key->buffer, tmpBuf, (size_t)_keySize + (size_t)_ivLength);
memset(tmpBuf, 0, sizeof(tmpBuf));

initKey(key, _blockCipher, _streamCipher, _keySize);
Expand Down Expand Up @@ -652,7 +652,7 @@ bool SSL_Cipher::compareKey(const CipherKey &A, const CipherKey &B) const {
rAssert(key1->keySize == _keySize);
rAssert(key2->keySize == _keySize);

return memcmp(key1->buffer, key2->buffer, _keySize + _ivLength) == 0;
return memcmp(key1->buffer, key2->buffer, (size_t)_keySize + (size_t)_ivLength) == 0;
}

int SSL_Cipher::encodedKeySize() const {
Expand Down