[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 12/13] qemu-ga: fix segv after failure to open log f
From: |
Michael Roth |
Subject: |
[Qemu-devel] [PATCH 12/13] qemu-ga: fix segv after failure to open log file |
Date: |
Tue, 15 May 2012 09:48:58 -0500 |
Currently, if we fail to open the specified log file (generally due to a
permissions issue), we'll assign NULL to the logfile handle (stderr,
initially) used by the logging routines, which can cause a segfault to
occur when we attempt to report the error before exiting.
Instead, only re-assign if the open() was successful.
Reviewed-by: Michal Privoznik <address@hidden>
Signed-off-by: Michael Roth <address@hidden>
---
qemu-ga.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/qemu-ga.c b/qemu-ga.c
index 3a88333..42e271f 100644
--- a/qemu-ga.c
+++ b/qemu-ga.c
@@ -836,12 +836,13 @@ int main(int argc, char **argv)
become_daemon(pid_filepath);
}
if (log_filepath) {
- s->log_file = fopen(log_filepath, "a");
- if (!s->log_file) {
+ FILE *log_file = fopen(log_filepath, "a");
+ if (!log_file) {
g_critical("unable to open specified log file: %s",
strerror(errno));
goto out_bad;
}
+ s->log_file = log_file;
}
}
--
1.7.4.1
- [Qemu-devel] [PULL] qemu-ga fixes for 1.1, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 02/13] qemu-ga: don't warn on no command return, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 04/13] qemu-ga: guest-suspend-disk: don't emit a success response, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 01/13] qapi: add support for command options, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 03/13] qemu-ga: guest-shutdown: don't emit a success response, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 05/13] qemu-ga: guest-suspend-ram: don't emit a success response, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 12/13] qemu-ga: fix segv after failure to open log file,
Michael Roth <=
- [Qemu-devel] [PATCH 06/13] qemu-ga: guest-suspend-hybrid: don't emit a success response, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 11/13] qemu-ga: guest-shutdown: use only async-signal-safe functions, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 08/13] qemu-ga: become_daemon(): reopen standard fds to /dev/null, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 07/13] qemu-ga: make reopen_fd_to_null() public, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 09/13] qemu-ga: guest-suspend: make the API synchronous, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 10/13] qemu-ga: guest-shutdown: become synchronous, Michael Roth, 2012/05/15
- [Qemu-devel] [PATCH 13/13] qemu-ga: align versioning with QEMU_VERSION, Michael Roth, 2012/05/15
- Re: [Qemu-devel] [PULL] qemu-ga fixes for 1.1, Luiz Capitulino, 2012/05/21