Consolidate rAssert statements in BlockNameIO

Whitespace cleanup
StreamNameIO rAssert statements should be the same
This commit is contained in:
Charles Munson 2016-03-24 16:34:52 +01:00
parent a0e02cb3ea
commit 6db69c2b0a
5 changed files with 14 additions and 16 deletions

View File

@ -137,17 +137,16 @@ int BlockNameIO::maxDecodedNameLen(int encodedNameLen) const {
int BlockNameIO::encodeName(const char *plaintextName, int length, uint64_t *iv,
char *encodedName, int bufferLength) const {
// copy the data into the encoding buffer..
rAssert(length <= (bufferLength - 2));
memcpy(encodedName + 2, plaintextName, length);
// Pad encryption buffer to block boundary..
int padding = _bs - length % _bs;
if (padding == 0) padding = _bs; // padding a full extra block!
rAssert(padding <= (bufferLength - length - 2));
rAssert(bufferLength >= length + 2 + padding);
memset(encodedName + length + 2, (unsigned char)padding, padding);
// copy the data into the encoding buffer..
memcpy(encodedName + 2, plaintextName, length);
// store the IV before it is modified by the MAC call.
uint64_t tmpIV = 0;
if (iv && _interface >= 3) tmpIV = *iv;

View File

@ -99,18 +99,17 @@ int StreamNameIO::encodeName(const char *plaintextName, int length,
// add on checksum bytes
unsigned char *encodeBegin;
rAssert(bufferLength >= length + 2);
if (_interface >= 1) {
// current versions store the checksum at the beginning
encodedName[0] = (mac >> 8) & 0xff;
encodedName[1] = (mac)&0xff;
encodeBegin = (unsigned char *)encodedName + 2;
rAssert(length <= (bufferLength - 2));
} else {
// encfs 0.x stored checksums at the end.
encodedName[length] = (mac >> 8) & 0xff;
encodedName[length + 1] = (mac)&0xff;
encodeBegin = (unsigned char *)encodedName;
rAssert(length <= bufferLength);
}
// stream encode the plaintext bytes