X-Git-Url: https://git.dogcows.com/gitweb?a=blobdiff_plain;ds=sidebyside;f=src%2Fbuffer.c;h=f99dcca1b2829bb978073d12657829fb5277df8b;hb=40ece6bf4dbf3f20bfbd8d26f4ce1c63dac80fa5;hp=f1034636b6de70a13eec147bc791580268135080;hpb=6f929b2c8998bab44ca81b01cd8e1381fb6e9dfe;p=chaz%2Ftar diff --git a/src/buffer.c b/src/buffer.c index f103463..f99dcca 100644 --- a/src/buffer.c +++ b/src/buffer.c @@ -1,13 +1,13 @@ /* Buffer management for tar. Copyright (C) 1988, 1992, 1993, 1994, 1996, 1997, 1999, 2000, 2001, - 2003, 2004, 2005, 2006 Free Software Foundation, Inc. + 2003, 2004, 2005, 2006, 2007 Free Software Foundation, Inc. Written by John Gilmore, on 1985-08-25. This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the - Free Software Foundation; either version 2, or (at your option) any later + Free Software Foundation; either version 3, or (at your option) any later version. This program is distributed in the hope that it will be useful, but @@ -26,7 +26,6 @@ #include #include -#include #include #include @@ -235,14 +234,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 +255,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; } @@ -586,7 +590,7 @@ _open_archive (enum access_mode wanted_access) } static void -do_checkpoint (bool write) +do_checkpoint (bool do_write) { if (checkpoint_option && !(++checkpoint % checkpoint_option)) { @@ -598,7 +602,7 @@ do_checkpoint (bool write) break; case checkpoint_text: - if (write) + if (do_write) /* TRANSLATORS: This is a ``checkpoint of write operation'', *not* ``Writing a checkpoint''. E.g. in Spanish ``Punto de comprobaci@'on de escritura'', @@ -1132,22 +1136,22 @@ try_new_volume () { size_t status; union block *header; - int access; + enum access_mode acc; switch (subcommand_option) { case APPEND_SUBCOMMAND: case CAT_SUBCOMMAND: case UPDATE_SUBCOMMAND: - access = ACCESS_UPDATE; + acc = ACCESS_UPDATE; break; default: - access = ACCESS_READ; + acc = ACCESS_READ; break; } - if (!new_volume (access)) + if (!new_volume (acc)) return true; while ((status = rmtread (archive, record_start->buffer, record_size))