tar2qfile: improved error handling
This commit is contained in:
parent
fb2f6688e8
commit
6938e68ee6
@ -388,7 +388,8 @@ enum {
|
||||
NEED_NOTHING,
|
||||
NEED_SKIP,
|
||||
NEED_READ,
|
||||
NEED_SYNC_TRAIL
|
||||
NEED_SYNC_TRAIL,
|
||||
INVALID_HEADER,
|
||||
};
|
||||
|
||||
|
||||
@ -417,9 +418,10 @@ ustar_rd (int fd, struct file_header * untrusted_hdr, char *buf, struct stat * s
|
||||
* we only get proper sized buffers
|
||||
*/
|
||||
fprintf(stderr,"Checking if valid header\n");
|
||||
if (ustar_id (buf, BLKMULT) < 0)
|
||||
return (-1);
|
||||
|
||||
if (ustar_id (buf, BLKMULT) < 0) {
|
||||
fprintf (stderr,"Invalid header\n");
|
||||
return INVALID_HEADER;
|
||||
}
|
||||
fprintf(stderr,"Valid header!\n");
|
||||
/* DISABLED: Internal to PAX
|
||||
arcn->org_name = arcn->name;
|
||||
@ -674,6 +676,7 @@ int tar_file_processor(int fd)
|
||||
size_t to_skip = 0;
|
||||
int sync_count = 0;
|
||||
while (size = read(fd, &buf, BLKMULT)) {
|
||||
if (size != -1) {
|
||||
fprintf(stderr,"Read %d bytes\n",size);
|
||||
ret = 0;
|
||||
if (current==NEED_SYNC_TRAIL) {
|
||||
@ -701,6 +704,7 @@ int tar_file_processor(int fd)
|
||||
current = NEED_READ;
|
||||
}
|
||||
i++;
|
||||
}
|
||||
//if (i >= 10)
|
||||
// exit(0);
|
||||
}
|
||||
@ -743,6 +747,7 @@ int main(int argc, char **argv)
|
||||
if (i <= 1) {
|
||||
// No argument specified. Use STDIN
|
||||
fprintf(stderr,"Using STDIN\n");
|
||||
set_block(0);
|
||||
tar_file_processor(fileno(stdin));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user