Skip to content

Commit

Permalink
dir: avoid heap-overflow during verify job
Browse files Browse the repository at this point in the history
Fixes #1210: Security vulnerability results in heap overflow in director
             when doing a Verify job against a file daemon.

Previously the code did not check that the target buffer that scanf()
wrote into was big enough to fit the data.
This patch now resizes the buffer to the size of the message buffer that
is being parsed ensuring that there is no heap overflow anymore.

(backport of 86c6fa4)
  • Loading branch information
arogge committed Jul 9, 2020
1 parent 2a0a0e2 commit 66c3f31
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions core/src/dird/fd_cmds.cc
Expand Up @@ -1101,6 +1101,7 @@ int GetAttributesAndPutInCatalog(JobControlRecord *jcr)
char *p, *fn;
PoolMem Digest(PM_MESSAGE); /* Either Verify opts or MD5/SHA1 digest */

Digest.check_size(fd->message_length);
if ((len = sscanf(fd->msg, "%ld %d %s", &file_index, &stream, Digest.c_str())) != 3) {
Jmsg(jcr, M_FATAL, 0, _("<filed: bad attributes, expected 3 fields got %d\n"
"message_length=%d msg=%s\n"), len, fd->message_length, fd->msg);
Expand Down

0 comments on commit 66c3f31

Please sign in to comment.