Merge remote-tracking branch 'qubesos/pr/2'

* qubesos/pr/2:
  qfile-unpacker: syncfs() to avoid qvm-move-to-vm data loss
This commit is contained in:
Marek Marczykowski-Górecki 2015-11-23 16:21:49 +01:00
commit 61f6054ce3
No known key found for this signature in database
GPG Key ID: 063938BA42CFA724

View File

@ -208,6 +208,9 @@ void process_one_file(struct file_header *untrusted_hdr)
int do_unpack(void)
{
struct file_header untrusted_hdr;
int cwd_fd;
int saved_errno;
total_bytes = total_files = 0;
/* initialize checksum */
crc32_sum = 0;
@ -222,6 +225,12 @@ int do_unpack(void)
do_exit(EDQUOT, untrusted_namebuf);
process_one_file(&untrusted_hdr);
}
saved_errno = errno;
cwd_fd = open(".", O_RDONLY);
if (cwd_fd >= 0 && syncfs(cwd_fd) == 0 && close(cwd_fd) == 0)
errno = saved_errno;
send_status_and_crc(errno, untrusted_namebuf);
return errno;
}