From: Nikos Mavrogiannopoulos Date: Fri, 11 Mar 2016 10:52:17 +0000 (+0100) Subject: certtool: better error handling in file_size() X-Git-Tag: gnutls_3_5_0~261 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1fcd82b7eee685bb77355e7386c525b915fc528b;p=thirdparty%2Fgnutls.git certtool: better error handling in file_size() --- diff --git a/src/certtool-common.c b/src/certtool-common.c index 6729681d18..dab6c59f99 100644 --- a/src/certtool-common.c +++ b/src/certtool-common.c @@ -53,8 +53,14 @@ unsigned long lbuffer_size = 0; static unsigned long file_size(FILE *fp) { unsigned long size; - unsigned long cur = ftell(fp); - fseek(fp, 0, SEEK_END); + long cur = ftell(fp); + + if (cur == -1) + return 0; + + if (fseek(fp, 0, SEEK_END) == -1) + return 0; + size = ftell(fp); fseek(fp, cur, SEEK_SET); return size;