always close file descriptor when opened, use standard types
MODIFY
src/afl-fuzz-queue.c
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) {

always close file descriptor when opened, use standard types