tar: bugfix: check for error on read()
authorBrett Gordon <beretta42@gmail.com>
Tue, 6 Jun 2017 22:42:09 +0000 (18:42 -0400)
committerBrett Gordon <beretta42@gmail.com>
Tue, 6 Jun 2017 22:42:09 +0000 (18:42 -0400)
Applications/util/tar.c

index 5af8897..40a5fd6 100644 (file)
@@ -454,8 +454,12 @@ static void extract(char *argv[])
 
        while (1) {
                x = read(infile, &h, 512);
+               if (x < 0 ){
+                       perror(ofile);
+                       exit(1);
+               }
                if (x < 512) {
-                       fprintf(stderr, "bad filesize\n");
+                       fprintf(stderr, "bad read size: %d\n", x);
                        exit(1);
                }