aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndre Heinecke <[email protected]>2015-03-17 09:48:09 +0000
committerWerner Koch <[email protected]>2015-03-17 11:03:36 +0000
commit0ed2cfcf054e286b238d4ddbbb3e929482849a47 (patch)
treef4fabc90e557fb3aad157788adc6038db0a707fe
parentcommon: Check option arguments for a valid range (diff)
downloadgnupg-0ed2cfcf054e286b238d4ddbbb3e929482849a47.tar.gz
gnupg-0ed2cfcf054e286b238d4ddbbb3e929482849a47.zip
gpgtar: Fix extracting files with !(size % 512)
* tools/gpgtar-extract.c (extract_regular): Handle size multiples of RECORDSIZE. -- If a hdr->size was a multiple of 512 the last record would not have been written and the files corrupted accordingly. GnuPG-bug-id: 1926 Signed-off-by: Andre Heinecke <[email protected]> Changed to use only if-else. Signed-off-by: Werner Koch <[email protected]> (cherry picked from commit 6cbbb0bec98e1acefc4c7163cc41a507469db920)
-rw-r--r--tools/gpgtar-extract.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/tools/gpgtar-extract.c b/tools/gpgtar-extract.c
index 736c7fc4b..b0d31e02e 100644
--- a/tools/gpgtar-extract.c
+++ b/tools/gpgtar-extract.c
@@ -73,7 +73,11 @@ extract_regular (estream_t stream, const char *dirname,
if (err)
goto leave;
n++;
- nbytes = (n < hdr->nrecords)? RECORDSIZE : (hdr->size % RECORDSIZE);
+ if (n < hdr->nrecords || (hdr->size && !(hdr->size % RECORDSIZE)))
+ nbytes = RECORDSIZE;
+ else
+ nbytes = (hdr->size % RECORDSIZE);
+
nwritten = es_fwrite (record, 1, nbytes, outfp);
if (nwritten != nbytes)
{