mirror of
https://github.com/vgough/encfs.git
synced 2024-11-22 16:03:34 +01:00
Consolidate rAssert statements in BlockNameIO
Whitespace cleanup StreamNameIO rAssert statements should be the same
This commit is contained in:
parent
a0e02cb3ea
commit
6db69c2b0a
@ -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;
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user