[glib: 1/3] fuzzing: Fix minor Coverity warning about return values




commit 895da996948d41d98acf40378b3f6c40efc0aace
Author: Philip Withnall <pwithnall endlessos org>
Date:   Fri Nov 13 14:12:18 2020 +0000

    fuzzing: Fix minor Coverity warning about return values
    
    ftell() could theoretically fail; handle that.
    
    Signed-off-by: Philip Withnall <pwithnall endlessos org>
    
    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);


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]