From c580dee4e170adad1ebdf901d32f0e1ed7d125b9 Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Mon, 21 Nov 2011 21:06:22 +0100 Subject: [PATCH 1/4] bsd_user: Fix potential null pointer dereference This bug was spotted by cppcheck. Using g_try_malloc0 (as does the linux-user code) fixes this. v2: Use g_free in bsdload.c, too. Thanks to Peter Maydell for this hint. Signed-off-by: Stefan Weil Signed-off-by: Blue Swirl --- bsd-user/bsdload.c | 2 +- bsd-user/elfload.c | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/bsd-user/bsdload.c b/bsd-user/bsdload.c index 6d9bb6fb4..2abc7136e 100644 --- a/bsd-user/bsdload.c +++ b/bsd-user/bsdload.c @@ -196,7 +196,7 @@ int loader_exec(const char * filename, char ** argv, char ** envp, /* Something went wrong, return the inode and free the argument pages*/ for (i=0 ; irss++; /* FIXME - check return value of memcpy_to_target() for failure */ memcpy_to_target(stack_base, bprm->page[i], TARGET_PAGE_SIZE); - free(bprm->page[i]); + g_free(bprm->page[i]); } stack_base += TARGET_PAGE_SIZE; } From f9db31a29e8ec43f73a9e948e980c569beef0136 Mon Sep 17 00:00:00 2001 From: Brad Date: Mon, 28 Nov 2011 19:53:49 -0500 Subject: [PATCH 2/4] configure: Enable build by default PIE / read-only relocation sections on OpenBSD amd64/i386. Enable build by default PIE / read-only relocation sections for the QEMU binaries on OpenBSD amd64/i386. Signed-off-by: Brad Smith Signed-off-by: Blue Swirl --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 5fbd81285..ca2530c23 100755 --- a/configure +++ b/configure @@ -1111,7 +1111,7 @@ fi if test "$pie" = ""; then case "$cpu-$targetos" in - i386-Linux|x86_64-Linux) + i386-Linux|x86_64-Linux|i386-OpenBSD|x86_64-OpenBSD) ;; *) pie="no" From 946fc459969b78966798399d5dc8ec7e6f4a1c1c Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 3 Dec 2011 22:32:21 +0100 Subject: [PATCH 3/4] w32: QEMU applications with SDL are always GUI applications Since commit 1d14ffa97eacd3cb722271eaf6f093038396eac4 (in 2005), QEMU applications on W32 don't use the default SDL compiler flags: Instead of a GUI application, a console application is created. This has disadvantages (there is always an empty console window) and no obvious reason, so this patch removes the strange flag modification. The SDL GUI applications still can be run from a console window and even send stdout and stderr to that console by setting environment variable SDL_STDIO_REDIRECT=no. Signed-off-by: Stefan Weil Signed-off-by: Blue Swirl --- configure | 3 --- 1 file changed, 3 deletions(-) diff --git a/configure b/configure index ca2530c23..2686657f0 100755 --- a/configure +++ b/configure @@ -1523,9 +1523,6 @@ EOF if compile_prog "$sdl_cflags" "$sdl_libs" ; then sdl_libs="$sdl_libs -lX11" fi - if test "$mingw32" = "yes" ; then - sdl_libs="`echo $sdl_libs | sed s/-mwindows//g` -mconsole" - fi libs_softmmu="$sdl_libs $libs_softmmu" fi From daf767b16aeb32e5b9a77066ba130fe723f875ca Mon Sep 17 00:00:00 2001 From: Stefan Weil Date: Sat, 3 Dec 2011 22:32:37 +0100 Subject: [PATCH 4/4] w32: Disable buffering for log file W32 does not support line buffering, but it supports unbuffered output. Unbuffered output is better for writing to qemu.log than fully buffered output because it also shows the latest log messages when an application crash occurs. Signed-off-by: Stefan Weil Signed-off-by: Blue Swirl --- exec.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/exec.c b/exec.c index 6b92198e6..d8b218017 100644 --- a/exec.c +++ b/exec.c @@ -1603,8 +1603,10 @@ void cpu_set_log(int log_flags) static char logfile_buf[4096]; setvbuf(logfile, logfile_buf, _IOLBF, sizeof(logfile_buf)); } -#elif !defined(_WIN32) - /* Win32 doesn't support line-buffering and requires size >= 2 */ +#elif defined(_WIN32) + /* Win32 doesn't support line-buffering, so use unbuffered output. */ + setvbuf(logfile, NULL, _IONBF, 0); +#else setvbuf(logfile, NULL, _IOLBF, 0); #endif log_append = 1;