]> git.ipfire.org Git - thirdparty/gnutls.git/commitdiff
certtool: better error handling in file_size()
authorNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 11 Mar 2016 10:52:17 +0000 (11:52 +0100)
committerNikos Mavrogiannopoulos <nmav@redhat.com>
Fri, 11 Mar 2016 10:52:17 +0000 (11:52 +0100)
src/certtool-common.c

index 6729681d187ada7cf2ffc4f83459422c488a90a3..dab6c59f998e78b49c07ec33259a01eec031bee8 100644 (file)
@@ -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;