From 895da996948d41d98acf40378b3f6c40efc0aace Mon Sep 17 00:00:00 2001 From: Philip Withnall Date: Fri, 13 Nov 2020 14:12:18 +0000 Subject: [PATCH] fuzzing: Fix minor Coverity warning about return values ftell() could theoretically fail; handle that. Signed-off-by: Philip Withnall Coverity CID: #1430667 --- fuzzing/driver.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/fuzzing/driver.c b/fuzzing/driver.c index 99e965ba6..f6d2396db 100644 --- a/fuzzing/driver.c +++ b/fuzzing/driver.c @@ -10,6 +10,7 @@ int main (int argc, char **argv) { FILE *f; + long tell_result; size_t n_read, len; unsigned char *buf; @@ -19,7 +20,9 @@ main (int argc, char **argv) f = fopen (argv[1], "r"); assert (f); fseek (f, 0, SEEK_END); - len = ftell (f); + tell_result = ftell (f); + assert (tell_result >= 0); + len = (size_t) tell_result; fseek (f, 0, SEEK_SET); buf = (unsigned char*) malloc (len); n_read = fread (buf, 1, len, f);