From 8d7a09b59624b60f492fcd4727a16a6b5a5deaef Mon Sep 17 00:00:00 2001 From: Eric Biggers Date: Sun, 11 Sep 2022 12:34:12 -0500 Subject: [PATCH] tools/afl-fuzz: fix ctype calculation --- tools/afl-fuzz/compress/fuzz.c | 2 +- tools/afl-fuzz/decompress/fuzz.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/afl-fuzz/compress/fuzz.c b/tools/afl-fuzz/compress/fuzz.c index ccda14b3..4c911725 100644 --- a/tools/afl-fuzz/compress/fuzz.c +++ b/tools/afl-fuzz/compress/fuzz.c @@ -30,7 +30,7 @@ int main(int argc, char *argv[]) assert(ret == 1); ret = read(fd, &level, 1); assert(ret == 1); - ctype = 1 + ((ctype - 1) % 3); /* 1-3 */ + ctype = 1 + ((uint8_t)(ctype - 1) % 3); /* 1-3 */ level = 1 + (level % 100); /* 1-100 */ usize = stbuf.st_size - 2; diff --git a/tools/afl-fuzz/decompress/fuzz.c b/tools/afl-fuzz/decompress/fuzz.c index 546a695e..b3d4b90c 100644 --- a/tools/afl-fuzz/decompress/fuzz.c +++ b/tools/afl-fuzz/decompress/fuzz.c @@ -25,7 +25,7 @@ int main(int argc, char *argv[]) return 0; ret = read(fd, &ctype, 1); assert(ret == 1); - ctype = 1 + ((ctype - 1) % 3); /* 1-3 */ + ctype = 1 + ((uint8_t)(ctype - 1) % 3); /* 1-3 */ csize = stbuf.st_size - 1; uspace = csize * 8; -- 2.43.0