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 c95b9e7 commit 916b63c
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions src/dird/fd_cmds.c
Expand Up @@ -953,6 +953,7 @@ int get_attributes_and_put_in_catalog(JCR *jcr)
char *p, *fn;
POOL_MEM Digest(PM_MESSAGE); /* Either Verify opts or MD5/SHA1 digest */

Digest.check_size(fd->msglen);
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"
"msglen=%d msg=%s\n"), len, fd->msglen, fd->msg);
Expand Down

0 comments on commit 916b63c

Please sign in to comment.