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 <aheinecke@intevation.de>

Changed to use only if-else.

Signed-off-by: Werner Koch <wk@gnupg.org>
(cherry picked from commit 6cbbb0bec9)
This commit is contained in:
Andre Heinecke 2015-03-17 10:48:09 +01:00 committed by Werner Koch
parent 25e2b27b00
commit 0ed2cfcf05
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B
1 changed files with 5 additions and 1 deletions

View File

@ -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)
{