From bbdb5ed67f9724c55f08defe41cbe1b0ac0804b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marek=20Marczykowski-G=C3=B3recki?= Date: Fri, 23 Jan 2015 00:11:55 +0100 Subject: [PATCH] filecopy: fix handling ENOENT error Do not fail when file was successfully created. I will test before commit. I will test before commit. I will... --- qrexec-lib/unpack.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/qrexec-lib/unpack.c b/qrexec-lib/unpack.c index 51caf94..3bc9dda 100644 --- a/qrexec-lib/unpack.c +++ b/qrexec-lib/unpack.c @@ -109,11 +109,13 @@ void process_one_file_reg(struct file_header *untrusted_hdr, /* make the file inaccessible until fully written */ if (use_tmpfile) { fdout = open(".", O_WRONLY | O_TMPFILE, 0700); - if (fdout < 0 && errno==ENOENT) { - /* if it fails, do not attempt further use - most likely kernel too old */ - use_tmpfile = 0; - } else - do_exit(errno, untrusted_name); + if (fdout < 0) { + if (errno==ENOENT) + /* if it fails, do not attempt further use - most likely kernel too old */ + use_tmpfile = 0; + else + do_exit(errno, untrusted_name); + } } if (fdout < 0) fdout = open(untrusted_name, O_WRONLY | O_CREAT | O_EXCL | O_NOFOLLOW, 0000); /* safe because of chroot */