libfetch: Fix failure to return to caller on error
authorJohn Marino <draco@marino.st>
Thu, 1 Nov 2012 20:17:48 +0000 (21:17 +0100)
committerJohn Marino <draco@marino.st>
Thu, 1 Nov 2012 21:56:18 +0000 (22:56 +0100)
As described in FreeBSD PR kern/171187, several error conditions were
missing return statements.

Taken-from: FreeBSD SVN 240595

lib/libfetch/file.c

index 0d093b3..d9530e5 100644 (file)
@@ -49,12 +49,15 @@ fetchXGetFile(struct url *u, struct url_stat *us, const char *flags)
 
        f = fopen(u->doc, "r");
 
-       if (f == NULL)
+       if (f == NULL) {
                fetch_syserr();
+               return (NULL);
+       }
 
        if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
                fclose(f);
                fetch_syserr();
+               return (NULL);
        }
 
        fcntl(fileno(f), F_SETFD, FD_CLOEXEC);
@@ -77,12 +80,15 @@ fetchPutFile(struct url *u, const char *flags)
        else
                f = fopen(u->doc, "w+");
 
-       if (f == NULL)
+       if (f == NULL) {
                fetch_syserr();
+               return (NULL);
+       }
 
        if (u->offset && fseeko(f, u->offset, SEEK_SET) == -1) {
                fclose(f);
                fetch_syserr();
+               return (NULL);
        }
 
        fcntl(fileno(f), F_SETFD, FD_CLOEXEC);