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

@ -265,7 +265,7 @@ create_directory (const char *dirprefix)
void
gpg_error_t
gpgtar_extract (const char *filename, int decrypt)
{
gpg_error_t err;
@ -285,7 +285,7 @@ gpgtar_extract (const char *filename, int decrypt)
{
err = gpg_error_from_syserror ();
log_error ("error opening '%s': %s\n", filename, gpg_strerror (err));
return;
return err;
}
}
else
@ -344,11 +344,12 @@ gpgtar_extract (const char *filename, int decrypt)
for (;;)
{
header = gpgtar_read_header (stream);
if (!header)
err = gpgtar_read_header (stream, &header);
if (err || header == NULL)
goto leave;
if (extract (stream, dirname, header))
err = extract (stream, dirname, header);
if (err)
goto leave;
xfree (header);
header = NULL;
@ -362,5 +363,5 @@ gpgtar_extract (const char *filename, int decrypt)
es_fclose (stream);
if (stream != cipher_stream)
es_fclose (cipher_stream);
return;
return err;
}