diff options
author | hexcoder- <heiko@hexco.de> | 2020-10-20 00:07:40 +0200 |
---|---|---|
committer | hexcoder- <heiko@hexco.de> | 2020-10-20 00:07:40 +0200 |
commit | d0cdbc48aebf88bc0cc519db553ca762f794296e (patch) | |
tree | e8010abe9be8b532faa10cf31aa609d105d5bf23 | |
parent | ac1c3b87015dd2c9b1bae0198f7925816aa63aec (diff) | |
download | afl++-d0cdbc48aebf88bc0cc519db553ca762f794296e.tar.gz |
always close file descriptor when opened, use standard types
-rw-r--r-- | src/afl-fuzz-queue.c | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c index 7f157121..1bda0835 100644 --- a/src/afl-fuzz-queue.c +++ b/src/afl-fuzz-queue.c @@ -211,13 +211,16 @@ static u8 check_if_text(struct queue_entry *q) { if (q->len < AFL_TXT_MIN_LEN) return 0; u8 buf[MAX_FILE]; - s32 fd, len = q->len, offset = 0, ascii = 0, utf8 = 0, comp; + int fd; + u32 len = q->len, offset = 0, ascii = 0, utf8 = 0; + ssize_t 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; + comp = read(fd, buf, len); close(fd); + if (comp != (ssize_t)len) return 0; + buf[len] = 0; while (offset < len) { |