Browse Source

catch case where we could BOF should_buffer[]

[skip ci]
Steffen Jaeckel 8 years ago
parent
commit
9a83397376
1 changed files with 5 additions and 0 deletions
  1. 5 0
      demos/hashsum.c

+ 5 - 0
demos/hashsum.c

@@ -98,6 +98,11 @@ static void check_file(int argn, int argc, char **argv)
          hash_len = space - s;
          hash_len /= 2;
 
+         if (hash_len > sizeof(should_buffer)) {
+            fprintf(stderr, "%s: hash too long\n", hashsum);
+            goto ERR;
+         }
+
          /* convert the hex-string back to binary */
          for (x = 0; x < hash_len; ++x) {
             should_buffer[x] = HEXOF(s[x*2]) << 4 | HEXOF(s[x*2 + 1]);