simply returning -1 on failure in bspatch, and leaving errx calls in main
authorMatthew Endsley <mendsley@gmail.com>
Mon, 14 May 2012 00:31:26 +0000 (17:31 -0700)
committerMatthew Endsley <mendsley@gmail.com>
Mon, 14 May 2012 08:04:24 +0000 (01:04 -0700)
bspatch.c

index 43fc578..3b002cd 100644 (file)
--- a/bspatch.c
+++ b/bspatch.c
@@ -86,18 +86,18 @@ int bspatch(const struct bspatch_request req)
                for(i=0;i<=2;i++) {
                        lenread = req.control.read(&req.control, buf, 8);
                        if (lenread != 8)
-                               errx(1, "Corrupt patch\n");
+                               return -1;
                        ctrl[i]=offtin(buf);
                };
 
                /* Sanity-check */
                if(newpos+ctrl[0]>req.newsize)
-                       errx(1,"Corrupt patch\n");
+                       return -1;
 
                /* Read diff string */
                lenread = req.diff.read(&req.diff, req.new + newpos, ctrl[0]);
                if (lenread != ctrl[0])
-                       errx(1, "Corrupt patch\n");
+                       return -1;
 
                /* Add old data to diff string */
                for(i=0;i<ctrl[0];i++)
@@ -110,12 +110,12 @@ int bspatch(const struct bspatch_request req)
 
                /* Sanity-check */
                if(newpos+ctrl[1]>req.newsize)
-                       errx(1,"Corrupt patch\n");
+                       return -1;
 
                /* Read extra string */
                lenread = req.extra.read(&req.extra, req.new + newpos, ctrl[1]);
                if (lenread != ctrl[1])
-                       errx(1, "Corrupt patch\n");
+                       return -1;
 
                /* Adjust pointers */
                newpos+=ctrl[1];