Check result of fread
authorAdam Dickmeiss <adam@indexdata.dk>
Mon, 3 Dec 2012 15:03:04 +0000 (16:03 +0100)
committerAdam Dickmeiss <adam@indexdata.dk>
Mon, 3 Dec 2012 15:03:04 +0000 (16:03 +0100)
util/yaz-url.c

index 56f152b..ed5d8bb 100644 (file)
@@ -45,7 +45,12 @@ static char *get_file(const char *fname, size_t *len)
     {
         buf = xmalloc(*len);
         fseek(inf, 0L, SEEK_SET);
-        (void) fread(buf, 1, *len, inf);
+        size_t r = fread(buf, 1, *len, inf);
+        if (r != *len)
+        {
+            yaz_log(YLOG_FATAL|YLOG_ERRNO, "short fread of %s", fname);
+            exit(1);
+        }
     }
     fclose(inf);
     return buf;