tar2qfile: multiples fixes to match the qfile format requirements

This commit is contained in:
Olivier MEDOC 2013-10-10 08:54:44 +02:00
parent 6938e68ee6
commit 864118cf10

View File

@ -456,6 +456,9 @@ ustar_rd (int fd, struct file_header * untrusted_hdr, char *buf, struct stat * s
untrusted_hdr->namelen = cnt + strlen(strncpy (dest, hd->name, untrusted_hdr->namelen = cnt + strlen(strncpy (dest, hd->name,
MIN(TNMSZ+1, sizeof (untrusted_namebuf) - cnt))); MIN(TNMSZ+1, sizeof (untrusted_namebuf) - cnt)));
// qfile count the \0 in the namelen
untrusted_hdr->namelen += 1;
fprintf(stderr,"Retrieved name len: %d\n",untrusted_hdr->namelen); fprintf(stderr,"Retrieved name len: %d\n",untrusted_hdr->namelen);
fprintf(stderr,"Retrieved name: %s\n",untrusted_namebuf); fprintf(stderr,"Retrieved name: %s\n",untrusted_namebuf);
@ -615,6 +618,8 @@ ustar_rd (int fd, struct file_header * untrusted_hdr, char *buf, struct stat * s
break; break;
case REGTYPE: case REGTYPE:
fprintf(stderr,"File is REGTYPE of size %d\n",sb->st_size); fprintf(stderr,"File is REGTYPE of size %d\n",sb->st_size);
// Restored POSIX stat file mode (because PAX format use its own file type)
untrusted_hdr->mode |= S_IFREG;
write_headers(untrusted_hdr, untrusted_namebuf); write_headers(untrusted_hdr, untrusted_namebuf);
ret = copy_file(1, fd, untrusted_hdr->filelen, &crc32_sum); ret = copy_file(1, fd, untrusted_hdr->filelen, &crc32_sum);
if (ret != COPY_FILE_OK) { if (ret != COPY_FILE_OK) {