]> Dogcows Code - chaz/tar/commitdiff
(check_compressed_archive): Detect files smaller than 512 bytes.
authorSergey Poznyakoff <gray@gnu.org.ua>
Fri, 24 Aug 2007 12:07:32 +0000 (12:07 +0000)
committerSergey Poznyakoff <gray@gnu.org.ua>
Fri, 24 Aug 2007 12:07:32 +0000 (12:07 +0000)
src/buffer.c

index 13e1c139048603bc2e6d5a339b83247754e3a705..cea5f253f438e62bdaa65e03565a8e67f9f4ff4d 100644 (file)
@@ -235,14 +235,16 @@ check_compressed_archive ()
 {
   struct zip_magic const *p;
   bool sfr;
-
+  bool short_file = false;
+  
   /* Prepare global data needed for find_next_block: */
   record_end = record_start; /* set up for 1st record = # 0 */
   sfr = read_full_records;
   read_full_records = true; /* Suppress fatal error on reading a partial
                               record */
-  find_next_block ();
-
+  if (find_next_block () == 0)
+    short_file = true;
+  
   /* Restore global values */
   read_full_records = sfr;
 
@@ -254,6 +256,9 @@ check_compressed_archive ()
     if (memcmp (record_start->buffer, p->magic, p->length) == 0)
       return p->type;
 
+  if (short_file)
+    ERROR ((0, 0, _("This does not look like a tar archive")));
+
   return ct_none;
 }
 
This page took 0.025582 seconds and 4 git commands to generate.