From 864118cf10a64dbc45561d29b9952211d339b88a Mon Sep 17 00:00:00 2001 From: Olivier MEDOC Date: Thu, 10 Oct 2013 08:54:44 +0200 Subject: [PATCH] tar2qfile: multiples fixes to match the qfile format requirements --- qubes-rpc/tar2qfile.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/qubes-rpc/tar2qfile.c b/qubes-rpc/tar2qfile.c index 0ce899d..7c3ddfa 100644 --- a/qubes-rpc/tar2qfile.c +++ b/qubes-rpc/tar2qfile.c @@ -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, 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: %s\n",untrusted_namebuf); @@ -615,6 +618,8 @@ ustar_rd (int fd, struct file_header * untrusted_hdr, char *buf, struct stat * s break; case REGTYPE: 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); ret = copy_file(1, fd, untrusted_hdr->filelen, &crc32_sum); if (ret != COPY_FILE_OK) {