Skip to content

Commit

Permalink
COMMON: Guard Blowfish buffer padding against overrun
Browse files Browse the repository at this point in the history
This fixes Coverity Scan issue #173470.
  • Loading branch information
DrMcCoy committed Dec 25, 2016
1 parent 57af082 commit a834f1f
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/common/blowfish.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,8 @@ MemoryReadStream *blowfishEBC(SeekableReadStream &input, const std::vector<byte>
if (input.read(buffer, toRead) != toRead)
throw Exception(kReadError);

std::memset(buffer + toRead, 0, kBlockSize - toRead);
if (toRead < kBlockSize)
std::memset(buffer + toRead, 0, kBlockSize - toRead);

blowfishECB(ctx, mode, buffer, data);

Expand Down

0 comments on commit a834f1f

Please sign in to comment.