Skip to content

Commit 9a83397

Browse files
committed
catch case where we could BOF should_buffer[]
[skip ci]
1 parent b621330 commit 9a83397

1 file changed

Lines changed: 5 additions & 0 deletions

File tree

demos/hashsum.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ static void check_file(int argn, int argc, char **argv)
9898
hash_len = space - s;
9999
hash_len /= 2;
100100

101+
if (hash_len > sizeof(should_buffer)) {
102+
fprintf(stderr, "%s: hash too long\n", hashsum);
103+
goto ERR;
104+
}
105+
101106
/* convert the hex-string back to binary */
102107
for (x = 0; x < hash_len; ++x) {
103108
should_buffer[x] = HEXOF(s[x*2]) << 4 | HEXOF(s[x*2 + 1]);

0 commit comments

Comments
 (0)