about summary refs log tree commit diff
path: root/src/afl-fuzz-queue.c
diff options
context:
space:
mode:
authorvan Hauser <vh@thc.org>2020-08-05 11:17:15 +0200
committervan Hauser <vh@thc.org>2020-08-05 11:17:15 +0200
commitf30ca1476c2d4d08d46fe9657ad4aa1d828eb578 (patch)
treec625c30a3e5db9918b8242ddcb7dff2c817832d2 /src/afl-fuzz-queue.c
parent0712d44cbcf1153972cd5457508dec5387e5b72e (diff)
downloadafl++-f30ca1476c2d4d08d46fe9657ad4aa1d828eb578.tar.gz
fix short write
Diffstat (limited to 'src/afl-fuzz-queue.c')
-rw-r--r--src/afl-fuzz-queue.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c
index 71874283..f35df914 100644
--- a/src/afl-fuzz-queue.c
+++ b/src/afl-fuzz-queue.c
@@ -112,8 +112,10 @@ static u8 check_if_text(struct queue_entry *q) {
   u8  buf[MAX_FILE];
   s32 fd, len = q->len, offset = 0, ascii = 0, utf8 = 0, comp;
 
+  if (len >= MAX_FILE) len = MAX_FILE - 1;
   if ((fd = open(q->fname, O_RDONLY)) < 0) return 0;
   if ((comp = read(fd, buf, len)) != len) return 0;
+  buf[len] = 0;
   close(fd);
 
   while (offset < len) {