1
0
Fork 0
mirror of git://git.gnupg.org/gnupg.git synced 2025-07-03 22:56:33 +02:00

gpgtar: Improve error messages.

* tools/gpgtar.h (struct tarinfo_s): New.
* tools/gpgtar.c (cmd, skip_crypto, files_from, null_names): Move
global vars more to the top.
(set_cmd): Rename 'cmd' to 'c'.
* tools/gpgtar-list.c (parse_header): Add arg 'info' and improve error
messages.
(read_header): Add arg 'info' and update counter.
(skip_data): Ditto.
(gpgtar_list): Pass info object to read functions.
(gpgtar_read_header): Add arg 'info'.
* tools/gpgtar-extract.c (gpgtar_extract): add arg 'info' and pass on.
(extract_regular): Add arg 'info' and update counter.
--

This now prints the block number of a header with error.

Signed-off-by: Werner Koch <wk@gnupg.org>
This commit is contained in:
Werner Koch 2019-03-06 17:46:40 +01:00
parent 05eff1f662
commit 72feb8fa82
No known key found for this signature in database
GPG key ID: E3FDFF218E45B72B
4 changed files with 89 additions and 43 deletions

View file

@ -41,12 +41,21 @@ struct
} opt;
/* An info structure to avoid global variables. */
struct tarinfo_s
{
unsigned long long nblocks; /* Count of processed blocks. */
unsigned long long headerblock; /* Number of current header block. */
};
typedef struct tarinfo_s *tarinfo_t;
/* The size of a tar record. All IO is done in chunks of this size.
Note that we don't care about blocking because this version of tar
is not expected to be used directly on a tape drive in fact it is
used in a pipeline with GPG and thus any blocking would be
useless. */
#define RECORDSIZE 512
#define RECORDSIZE 512
/* Description of the USTAR header format. */
@ -64,16 +73,16 @@ struct ustar_raw_header
char magic[6];
char version[2];
char uname[32];
char gname[32];
char devmajor[8];
char gname[32];
char devmajor[8];
char devminor[8];
char prefix[155];
char prefix[155];
char pad[12];
};
/* Filetypes as defined by USTAR. */
typedef enum
typedef enum
{
TF_REGULAR,
TF_HARDLINK,
@ -93,7 +102,7 @@ struct tar_header_s;
typedef struct tar_header_s *tar_header_t;
struct tar_header_s
{
tar_header_t next; /* Used to build a linked list iof entries. */
tar_header_t next; /* Used to build a linked list of entries. */
unsigned long mode; /* The file mode. */
unsigned long nlink; /* Number of hard links. */
@ -106,7 +115,7 @@ struct tar_header_s
that 32 bit and thus allows tracking
times beyond 2106. */
typeflag_t typeflag; /* The type of the file. */
unsigned long long nrecords; /* Number of data records. */
@ -126,7 +135,8 @@ gpg_error_t gpgtar_extract (const char *filename, int decrypt);
/*-- gpgtar-list.c --*/
gpg_error_t gpgtar_list (const char *filename, int decrypt);
gpg_error_t gpgtar_read_header (estream_t stream, tar_header_t *r_header);
gpg_error_t gpgtar_read_header (estream_t stream, tarinfo_t info,
tar_header_t *r_header);
void gpgtar_print_header (tar_header_t header, estream_t out);