2010-06-07 15:33:02 +02:00
|
|
|
|
/* gpgtar-extract.c - Extract from a TAR archive
|
|
|
|
|
* Copyright (C) 2010 Free Software Foundation, Inc.
|
|
|
|
|
*
|
|
|
|
|
* This file is part of GnuPG.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG 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 3 of the License, or
|
|
|
|
|
* (at your option) any later version.
|
|
|
|
|
*
|
|
|
|
|
* GnuPG is distributed in the hope that it will be useful,
|
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
*
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
2016-11-05 12:02:19 +01:00
|
|
|
|
* along with this program; if not, see <https://www.gnu.org/licenses/>.
|
2010-06-07 15:33:02 +02:00
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
#include <errno.h>
|
|
|
|
|
#include <stdio.h>
|
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
#include <string.h>
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
#include <sys/stat.h>
|
|
|
|
|
#include <unistd.h>
|
|
|
|
|
#include <assert.h>
|
|
|
|
|
|
2017-03-07 12:21:23 +01:00
|
|
|
|
#include "../common/i18n.h"
|
2015-12-14 09:38:46 +01:00
|
|
|
|
#include "../common/exectool.h"
|
2010-06-07 15:33:02 +02:00
|
|
|
|
#include "../common/sysutils.h"
|
2016-05-24 15:54:48 +02:00
|
|
|
|
#include "../common/ccparray.h"
|
2010-06-07 15:33:02 +02:00
|
|
|
|
#include "gpgtar.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
extract_regular (estream_t stream, const char *dirname,
|
2019-03-06 17:46:40 +01:00
|
|
|
|
tarinfo_t info, tar_header_t hdr)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char record[RECORDSIZE];
|
|
|
|
|
size_t n, nbytes, nwritten;
|
|
|
|
|
char *fname;
|
|
|
|
|
estream_t outfp = NULL;
|
|
|
|
|
|
|
|
|
|
fname = strconcat (dirname, "/", hdr->name, NULL);
|
|
|
|
|
if (!fname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
log_error ("error creating filename: %s\n", gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
err = 0;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2015-11-26 17:05:12 +01:00
|
|
|
|
if (opt.dry_run)
|
|
|
|
|
outfp = es_fopenmem (0, "wb");
|
|
|
|
|
else
|
|
|
|
|
outfp = es_fopen (fname, "wb");
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (!outfp)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error creating '%s': %s\n", fname, gpg_strerror (err));
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (n=0; n < hdr->nrecords;)
|
|
|
|
|
{
|
|
|
|
|
err = read_record (stream, record);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
info->nblocks++;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
n++;
|
2015-03-17 10:48:09 +01:00
|
|
|
|
if (n < hdr->nrecords || (hdr->size && !(hdr->size % RECORDSIZE)))
|
|
|
|
|
nbytes = RECORDSIZE;
|
|
|
|
|
else
|
|
|
|
|
nbytes = (hdr->size % RECORDSIZE);
|
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
nwritten = es_fwrite (record, 1, nbytes, outfp);
|
|
|
|
|
if (nwritten != nbytes)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error writing '%s': %s\n", fname, gpg_strerror (err));
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
/* Fixme: Set permissions etc. */
|
|
|
|
|
|
|
|
|
|
leave:
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (!err && opt.verbose)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info ("extracted '%s'\n", fname);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
es_fclose (outfp);
|
|
|
|
|
if (err && fname && outfp)
|
|
|
|
|
{
|
|
|
|
|
if (gnupg_remove (fname))
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error removing incomplete file '%s': %s\n",
|
2010-06-07 15:33:02 +02:00
|
|
|
|
fname, gpg_strerror (gpg_error_from_syserror ()));
|
|
|
|
|
}
|
|
|
|
|
xfree (fname);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpg_error_t
|
|
|
|
|
extract_directory (const char *dirname, tar_header_t hdr)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
char *fname;
|
2010-07-16 15:19:45 +02:00
|
|
|
|
size_t prefixlen;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
prefixlen = strlen (dirname) + 1;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
fname = strconcat (dirname, "/", hdr->name, NULL);
|
|
|
|
|
if (!fname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
log_error ("error creating filename: %s\n", gpg_strerror (err));
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
err = 0;
|
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (fname[strlen (fname)-1] == '/')
|
|
|
|
|
fname[strlen (fname)-1] = 0;
|
|
|
|
|
|
2015-11-26 17:05:12 +01:00
|
|
|
|
if (! opt.dry_run && gnupg_mkdir (fname, "-rwx------"))
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2016-10-04 12:44:14 +02:00
|
|
|
|
if (gpg_err_code (err) == GPG_ERR_EEXIST)
|
|
|
|
|
{
|
|
|
|
|
/* Ignore existing directories while extracting. */
|
|
|
|
|
err = 0;
|
|
|
|
|
}
|
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (gpg_err_code (err) == GPG_ERR_ENOENT)
|
|
|
|
|
{
|
|
|
|
|
/* Try to create the directory with parents but keep the
|
|
|
|
|
original error code in case of a failure. */
|
|
|
|
|
char *p;
|
|
|
|
|
int rc = 0;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
for (p = fname+prefixlen; (p = strchr (p, '/')); p++)
|
|
|
|
|
{
|
|
|
|
|
*p = 0;
|
|
|
|
|
rc = gnupg_mkdir (fname, "-rwx------");
|
|
|
|
|
*p = '/';
|
|
|
|
|
if (rc)
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
if (!rc && !gnupg_mkdir (fname, "-rwx------"))
|
|
|
|
|
err = 0;
|
|
|
|
|
}
|
|
|
|
|
if (err)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error creating directory '%s': %s\n",
|
2010-07-16 15:19:45 +02:00
|
|
|
|
fname, gpg_strerror (err));
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
leave:
|
2010-07-16 15:19:45 +02:00
|
|
|
|
if (!err && opt.verbose)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info ("created '%s/'\n", fname);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
xfree (fname);
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static gpg_error_t
|
2019-03-06 17:46:40 +01:00
|
|
|
|
extract (estream_t stream, const char *dirname, tarinfo_t info,
|
|
|
|
|
tar_header_t hdr)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
size_t n;
|
|
|
|
|
|
|
|
|
|
n = strlen (hdr->name);
|
|
|
|
|
#ifdef HAVE_DOSISH_SYSTEM
|
|
|
|
|
if (strchr (hdr->name, '\\'))
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("filename '%s' contains a backslash - "
|
2010-06-07 15:33:02 +02:00
|
|
|
|
"can't extract on this system\n", hdr->name);
|
|
|
|
|
return gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
}
|
|
|
|
|
#endif /*HAVE_DOSISH_SYSTEM*/
|
|
|
|
|
|
|
|
|
|
if (!n
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|| strstr (hdr->name, "//")
|
|
|
|
|
|| strstr (hdr->name, "/../")
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|| !strncmp (hdr->name, "../", 3)
|
|
|
|
|
|| (n >= 3 && !strcmp (hdr->name+n-3, "/.." )))
|
|
|
|
|
{
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("filename '%s' as suspicious parts - not extracting\n",
|
2010-06-07 15:33:02 +02:00
|
|
|
|
hdr->name);
|
|
|
|
|
return gpg_error (GPG_ERR_INV_NAME);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (hdr->typeflag == TF_REGULAR || hdr->typeflag == TF_UNKNOWN)
|
2019-03-06 17:46:40 +01:00
|
|
|
|
err = extract_regular (stream, dirname, info, hdr);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
else if (hdr->typeflag == TF_DIRECTORY)
|
|
|
|
|
err = extract_directory (dirname, hdr);
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
char record[RECORDSIZE];
|
|
|
|
|
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info ("unsupported file type %d for '%s' - skipped\n",
|
2010-07-16 15:19:45 +02:00
|
|
|
|
(int)hdr->typeflag, hdr->name);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
for (err = 0, n=0; !err && n < hdr->nrecords; n++)
|
2019-03-06 17:46:40 +01:00
|
|
|
|
{
|
|
|
|
|
err = read_record (stream, record);
|
|
|
|
|
if (!err)
|
|
|
|
|
info->nblocks++;
|
|
|
|
|
}
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|
|
|
|
|
return err;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/* Create a new directory to be used for extracting the tarball.
|
|
|
|
|
Returns the name of the directory which must be freed by the
|
|
|
|
|
caller. In case of an error a diagnostic is printed and NULL
|
|
|
|
|
returned. */
|
|
|
|
|
static char *
|
|
|
|
|
create_directory (const char *dirprefix)
|
|
|
|
|
{
|
|
|
|
|
gpg_error_t err = 0;
|
2010-07-16 15:19:45 +02:00
|
|
|
|
char *prefix_buffer = NULL;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
char *dirname = NULL;
|
2010-07-16 15:19:45 +02:00
|
|
|
|
size_t n;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
int idx;
|
|
|
|
|
|
2010-07-16 15:19:45 +02:00
|
|
|
|
/* Remove common suffixes. */
|
|
|
|
|
n = strlen (dirprefix);
|
2013-11-18 14:09:47 +01:00
|
|
|
|
if (n > 4 && (!compare_filenames (dirprefix + n - 4, EXTSEP_S GPGEXT_GPG)
|
2010-07-16 15:19:45 +02:00
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pgp")
|
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "asc")
|
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "pem")
|
2010-08-26 10:47:42 +02:00
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7m")
|
2010-07-16 15:19:45 +02:00
|
|
|
|
|| !compare_filenames (dirprefix + n - 4, EXTSEP_S "p7e")))
|
|
|
|
|
{
|
|
|
|
|
prefix_buffer = xtrystrdup (dirprefix);
|
|
|
|
|
if (!prefix_buffer)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
prefix_buffer[n-4] = 0;
|
|
|
|
|
dirprefix = prefix_buffer;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2010-06-07 15:33:02 +02:00
|
|
|
|
for (idx=1; idx < 5000; idx++)
|
|
|
|
|
{
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
dirname = xtryasprintf ("%s_%d_", dirprefix, idx);
|
|
|
|
|
if (!dirname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
if (!gnupg_mkdir (dirname, "-rwx------"))
|
2010-07-16 15:19:45 +02:00
|
|
|
|
goto leave; /* Ready. */
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (errno != EEXIST && errno != ENOTDIR)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
}
|
2010-07-16 15:19:45 +02:00
|
|
|
|
err = gpg_error (GPG_ERR_LIMIT_REACHED);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
if (err)
|
|
|
|
|
{
|
|
|
|
|
log_error ("error creating an extract directory: %s\n",
|
|
|
|
|
gpg_strerror (err));
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
dirname = NULL;
|
|
|
|
|
}
|
2010-07-16 15:19:45 +02:00
|
|
|
|
xfree (prefix_buffer);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
return dirname;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2015-11-25 13:39:50 +01:00
|
|
|
|
gpg_error_t
|
2015-11-24 18:39:30 +01:00
|
|
|
|
gpgtar_extract (const char *filename, int decrypt)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
{
|
|
|
|
|
gpg_error_t err;
|
|
|
|
|
estream_t stream;
|
2015-11-24 18:39:30 +01:00
|
|
|
|
estream_t cipher_stream = NULL;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
tar_header_t header = NULL;
|
|
|
|
|
const char *dirprefix = NULL;
|
|
|
|
|
char *dirname = NULL;
|
2019-03-06 17:46:40 +01:00
|
|
|
|
struct tarinfo_s tarinfo_buffer;
|
|
|
|
|
tarinfo_t tarinfo = &tarinfo_buffer;
|
|
|
|
|
|
|
|
|
|
memset (&tarinfo_buffer, 0, sizeof tarinfo_buffer);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
|
|
|
|
if (filename)
|
|
|
|
|
{
|
2010-08-25 12:31:47 +02:00
|
|
|
|
if (!strcmp (filename, "-"))
|
2016-06-28 15:03:07 +02:00
|
|
|
|
stream = es_stdin;
|
2010-08-25 12:31:47 +02:00
|
|
|
|
else
|
|
|
|
|
stream = es_fopen (filename, "rb");
|
2010-06-07 15:33:02 +02:00
|
|
|
|
if (!stream)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_error ("error opening '%s': %s\n", filename, gpg_strerror (err));
|
2015-11-25 13:39:50 +01:00
|
|
|
|
return err;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
2013-11-18 14:09:47 +01:00
|
|
|
|
stream = es_stdin;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
2010-08-25 12:31:47 +02:00
|
|
|
|
if (stream == es_stdin)
|
|
|
|
|
es_set_binary (es_stdin);
|
2010-07-16 15:19:45 +02:00
|
|
|
|
|
2015-11-24 18:39:30 +01:00
|
|
|
|
if (decrypt)
|
|
|
|
|
{
|
2015-11-30 16:21:22 +01:00
|
|
|
|
strlist_t arg;
|
2016-05-24 15:54:48 +02:00
|
|
|
|
ccparray_t ccp;
|
2015-11-30 16:21:22 +01:00
|
|
|
|
const char **argv;
|
|
|
|
|
|
2015-11-24 18:39:30 +01:00
|
|
|
|
cipher_stream = stream;
|
|
|
|
|
stream = es_fopenmem (0, "rwb");
|
|
|
|
|
if (! stream)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2015-11-30 16:21:22 +01:00
|
|
|
|
|
2016-05-24 15:54:48 +02:00
|
|
|
|
ccparray_init (&ccp, 0);
|
|
|
|
|
|
|
|
|
|
ccparray_put (&ccp, "--decrypt");
|
|
|
|
|
for (arg = opt.gpg_arguments; arg; arg = arg->next)
|
|
|
|
|
ccparray_put (&ccp, arg->d);
|
|
|
|
|
|
|
|
|
|
ccparray_put (&ccp, NULL);
|
|
|
|
|
argv = ccparray_get (&ccp, NULL);
|
|
|
|
|
if (!argv)
|
2015-11-30 16:21:22 +01:00
|
|
|
|
{
|
|
|
|
|
err = gpg_error_from_syserror ();
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2015-12-14 09:38:46 +01:00
|
|
|
|
err = gnupg_exec_tool_stream (opt.gpg_program, argv,
|
2016-05-28 00:07:09 +02:00
|
|
|
|
cipher_stream, NULL, stream, NULL, NULL);
|
2015-11-30 16:21:22 +01:00
|
|
|
|
xfree (argv);
|
2015-11-24 18:39:30 +01:00
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
|
|
|
|
|
err = es_fseek (stream, 0, SEEK_SET);
|
|
|
|
|
if (err)
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
|
|
|
|
|
2015-11-25 18:29:22 +01:00
|
|
|
|
if (opt.directory)
|
|
|
|
|
dirname = xtrystrdup (opt.directory);
|
|
|
|
|
else
|
2010-07-16 15:19:45 +02:00
|
|
|
|
{
|
2017-11-15 09:54:05 +01:00
|
|
|
|
if (opt.filename)
|
2015-11-25 18:29:22 +01:00
|
|
|
|
{
|
2017-11-15 09:54:05 +01:00
|
|
|
|
dirprefix = strrchr (opt.filename, '/');
|
2015-11-25 18:29:22 +01:00
|
|
|
|
if (dirprefix)
|
|
|
|
|
dirprefix++;
|
|
|
|
|
else
|
2017-11-15 09:54:05 +01:00
|
|
|
|
dirprefix = opt.filename;
|
2015-11-25 18:29:22 +01:00
|
|
|
|
}
|
2017-11-15 09:54:05 +01:00
|
|
|
|
else if (filename)
|
2015-11-25 18:29:22 +01:00
|
|
|
|
{
|
2017-11-15 09:54:05 +01:00
|
|
|
|
dirprefix = strrchr (filename, '/');
|
2015-11-25 18:29:22 +01:00
|
|
|
|
if (dirprefix)
|
|
|
|
|
dirprefix++;
|
|
|
|
|
else
|
2017-11-15 09:54:05 +01:00
|
|
|
|
dirprefix = filename;
|
2015-11-25 18:29:22 +01:00
|
|
|
|
}
|
2010-07-16 15:19:45 +02:00
|
|
|
|
|
2015-11-25 18:29:22 +01:00
|
|
|
|
if (!dirprefix || !*dirprefix)
|
|
|
|
|
dirprefix = "GPGARCH";
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
2015-11-25 18:29:22 +01:00
|
|
|
|
dirname = create_directory (dirprefix);
|
|
|
|
|
if (!dirname)
|
|
|
|
|
{
|
|
|
|
|
err = gpg_error (GPG_ERR_GENERAL);
|
|
|
|
|
goto leave;
|
|
|
|
|
}
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (opt.verbose)
|
2012-06-05 19:29:22 +02:00
|
|
|
|
log_info ("extracting to '%s/'\n", dirname);
|
2010-06-07 15:33:02 +02:00
|
|
|
|
|
|
|
|
|
for (;;)
|
|
|
|
|
{
|
2019-03-06 17:46:40 +01:00
|
|
|
|
err = gpgtar_read_header (stream, tarinfo, &header);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
if (err || header == NULL)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
2013-11-18 14:09:47 +01:00
|
|
|
|
|
2019-03-06 17:46:40 +01:00
|
|
|
|
err = extract (stream, dirname, tarinfo, header);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
if (err)
|
2010-06-07 15:33:02 +02:00
|
|
|
|
goto leave;
|
|
|
|
|
xfree (header);
|
|
|
|
|
header = NULL;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
leave:
|
|
|
|
|
xfree (header);
|
|
|
|
|
xfree (dirname);
|
|
|
|
|
if (stream != es_stdin)
|
|
|
|
|
es_fclose (stream);
|
2015-11-24 18:39:30 +01:00
|
|
|
|
if (stream != cipher_stream)
|
|
|
|
|
es_fclose (cipher_stream);
|
2015-11-25 13:39:50 +01:00
|
|
|
|
return err;
|
2010-06-07 15:33:02 +02:00
|
|
|
|
}
|