Commit 2b720018 authored by Laszlo Ersek's avatar Laszlo Ersek Committed by Michael Roth
Browse files

qga: unlink just created guest-file if fchmod() or fdopen() fails on it



We shouldn't allow guest filesystem pollution on error paths.

Suggested-by: default avatarEric Blake <eblake@redhat.com>
Signed-off-by: default avatarLaszlo Ersek <lersek@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
Reviewed-by: default avatarLuiz Capitulino <lcapitulino@redhat.com>
Signed-off-by: default avatarMichael Roth <mdroth@linux.vnet.ibm.com>
parent 8fe6bbca
Loading
Loading
Loading
Loading
+3 −0
Original line number Diff line number Diff line
@@ -355,6 +355,9 @@ safe_open_or_create(const char *path, const char *mode, Error **err)
            }

            close(fd);
            if (oflag & O_CREAT) {
                unlink(path);
            }
        }
    }