Commits

Greg Ward  committed 02c2e64

fossil: fix buffer overflow.

If fossil prints >= 2048 bytes, fread() would have read all of them
and filled up buf. Then passing that buf to strbuf() is bad news,
since strbuf() expects a NUL-terminated string. Fix by reading at
most 2047 bytes and terminating the string.

  • Participants
  • Parent commits 29c6e68

Comments (0)

Files changed (1)

File src/fossil.c

         return NULL;
     }
 
-    fread(buf, sizeof(char), 2048, stream);
+    size_t rlen = fread(buf, sizeof(char), 2047, stream);
+    buf[rlen] = '\0';
     pclose(stream);
 
     if (context->options->show_branch) {