diff options
author | van Hauser <vh@thc.org> | 2020-06-20 09:21:02 +0200 |
---|---|---|
committer | van Hauser <vh@thc.org> | 2020-06-20 09:21:02 +0200 |
commit | 5ca303393f0c3646c1ad032787f85c340c3aebbc (patch) | |
tree | 852422e665d8ad97e5e374f6b81b276138a07bf1 /src/afl-fuzz-queue.c | |
parent | de2c565953228a52b2ac75b778b27aab983151c6 (diff) | |
download | afl++-5ca303393f0c3646c1ad032787f85c340c3aebbc.tar.gz |
fix ascii percentage calc
Diffstat (limited to 'src/afl-fuzz-queue.c')
-rw-r--r-- | src/afl-fuzz-queue.c | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/src/afl-fuzz-queue.c b/src/afl-fuzz-queue.c index f6c0e830..8f2d5a24 100644 --- a/src/afl-fuzz-queue.c +++ b/src/afl-fuzz-queue.c @@ -108,7 +108,7 @@ 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, percent, type, comp; + s32 fd, len = q->len, offset = 0, ascii = 0, utf8 = 0, type, comp; if ((fd = open(q->fname, O_RDONLY)) < 0) return 0; if ((comp = read(fd, buf, len)) != len) return 0; @@ -193,22 +193,14 @@ static u8 check_if_text(struct queue_entry *q) { } - if (utf8 >= ascii) { - - type = 2; - percent = (utf8 * 100) / comp; - - } else { - - type = 1; - percent = (ascii * 100) / comp; - - } - - if (percent >= AFL_TXT_MIN_PERCENT) - return type; - else - return 0; + u32 percent_utf8 = (utf8 * 100) / comp; + u32 percent_ascii = (ascii * 100) / len; + + if (percent_utf8 >= percent_ascii && percent_utf8 >= AFL_TXT_MIN_PERCENT) + return 2; + if (percent_utf8 >= AFL_TXT_MIN_PERCENT) + return 1; + return 0; } |