1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-02 22:46:30 +02:00

tools/gpgtar: Improve error handling.

* tools/gpgtar-create.c (gpgtar_create): Return an error code, fix
error handling.
* tools/gpgtar-extract.c (gpgtar_extract): Likewise.
* tools/gpgtar-list.c (read_header): Return an error code.
(gpgtar_list): Return an error code, fix error handling.
(gpgtar_read_header): Return an error code.
* tools/gpgtar.c: Add missing include.
(main): Print an generic error message if a command failed and no
error has been printed yet.
* tools/gpgtar.h (gpgtar_{create,extract,list,read_header}): Fix the
prototypes accordingly.

Signed-off-by: Justus Winter <justus@g10code.com>
This commit is contained in:
Justus Winter 2015-11-25 13:39:50 +01:00
parent 40dbee86f3
commit f76fb047c1
5 changed files with 51 additions and 36 deletions

View file

@ -740,7 +740,7 @@ write_eof_mark (estream_t stream)
/* Create a new tarball using the names in the array INPATTERN. If
INPATTERN is NULL take the pattern as null terminated strings from
stdin. */
void
gpg_error_t
gpgtar_create (char **inpattern, int encrypt)
{
gpg_error_t err = 0;
@ -903,16 +903,19 @@ gpgtar_create (char **inpattern, int encrypt)
leave:
if (!err)
{
gpg_error_t first_err;
if (outstream != es_stdout)
err = es_fclose (outstream);
first_err = es_fclose (outstream);
else
err = es_fflush (outstream);
first_err = es_fflush (outstream);
outstream = NULL;
if (cipher_stream != es_stdout)
err = es_fclose (cipher_stream);
else
err = es_fflush (cipher_stream);
cipher_stream = NULL;
if (! err)
err = first_err;
}
if (err)
{
@ -931,4 +934,5 @@ gpgtar_create (char **inpattern, int encrypt)
scanctrl->flist = hdr->next;
xfree (hdr);
}
return err;
}