From f0a90ff91f426a5d1ce96bdf5f61d18cf37e5fb7 Mon Sep 17 00:00:00 2001 From: Adam Dickmeiss Date: Mon, 3 Dec 2012 16:03:04 +0100 Subject: [PATCH] Check result of fread --- util/yaz-url.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/util/yaz-url.c b/util/yaz-url.c index 56f152b..ed5d8bb 100644 --- a/util/yaz-url.c +++ b/util/yaz-url.c @@ -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; -- 1.7.10.4