[Qemu-devel] Re: [PATCH] qcow2: don't ignore failed update_refcount

2010-02-08 Thread Jim Meyering
Kevin Wolf wrote: ... I'm currently working on fixing exactly this, and unfortunaly, no, it's not that easy. What you introduce looks like proper error handling at first sight, but what happens in fact is that while the current write request correctly fails now we're running with corrupted

[Qemu-devel] [PATCH] don't dereference NULL after failed strdup

2010-02-08 Thread Jim Meyering
2001 From: Jim Meyering meyer...@redhat.com Date: Mon, 8 Feb 2010 18:29:29 +0100 Subject: [PATCH] don't dereference NULL after failed strdup Handle failing strdup by replacing each use with qemu_strdup, so as not to dereference NULL or trigger a failing assertion. * block/curl.c (curl_open): s

[Qemu-devel] [PATCH 04/22] hw/9pfs: avoid buffer overrun

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com v9fs_add_dir_node and qemu_v9fs_synth_add_file used strncpy to form node-name, which requires NUL-termination, but strncpy does not ensure NUL-termination. Use pstrcpy, which does. Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/9pfs/virtio-9p

[Qemu-devel] [PATCH 07/22] ppc: avoid buffer overrun: use pstrcpy, not strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com A terminal NUL is required by caller's use of strchr. It's better not to use strncpy at all, since there is no need to zero out hundreds of trailing bytes for each iteration. Signed-off-by: Jim Meyering meyer...@redhat.com --- target-ppc/kvm.c | 2 +- 1

[Qemu-devel] [PATCH 18/22] acpi: remove strzcpy (strncpy-identical) function; just use strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Adjust all uses s/strzcpy/strncpy/ and mark these uses of strncpy as ok. Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/acpi.c | 24 1 file changed, 8 insertions(+), 16 deletions(-) diff --git a/hw/acpi.c b/hw/acpi.c index

[Qemu-devel] [PATCH 09/22] ui/vnc: simplify and avoid strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Don't bother with strncpy. There's no need for its zero-fill. Use g_strndup in place of g_malloc+strncpy+NUL-terminate. Signed-off-by: Jim Meyering meyer...@redhat.com --- ui/vnc-auth-sasl.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff

Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup

2012-05-09 Thread Jim Meyering
Peter Maydell wrote: On 9 May 2012 10:23, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Remove unnecessary and unchecked uses of strdup, and add a comment that this strncpy use is ok. Signed-off-by: Jim Meyering meyer...@redhat.com ---  linux-user/elfload.c

[Qemu-devel] [PATCH 06/22] os-posix: avoid buffer overrun

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com os_set_proc_name: Use pstrcpy, in place of strncpy and the ineffectual preceding assignment: name[sizeof(name) - 1] = 0; Signed-off-by: Jim Meyering meyer...@redhat.com --- os-posix.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/os

[Qemu-devel] [PATCH 03/22] vmdk: relative_path: avoid buffer overrun

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com strncpy does not guarantee NUL-termination. Setting dest[n-1] = '\0' *before* calling strncpy(dest, src, n-1) is a no-op. Use pstrcpy to ensure NUL-termination, not strncpy. Signed-off-by: Jim Meyering meyer...@redhat.com --- block/vmdk.c | 3 +-- 1 file

[Qemu-devel] [PATCH 01/22] block: avoid buffer overrun by using pstrcpy, not strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Also, use PATH_MAX, rather than the arbitrary 1024. Using PATH_MAX is more consistent with other filename-related variables in this file, like backing_filename and tmp_filename. Signed-off-by: Jim Meyering meyer...@redhat.com --- block.c | 5 +++-- 1 file

[Qemu-devel] [PATCH 17/22] libcacard/vcard_emul_nss: use pstrcpy in place of strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Replace strncpy+NUL-terminate use with use of pstrcpy. This requires linking with cutils.o (or else vssclient doesn't link), so add that in the Makefile. Signed-off-by: Jim Meyering meyer...@redhat.com --- libcacard/Makefile | 2 +- libcacard

Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup

2012-05-09 Thread Jim Meyering
Peter Maydell wrote: On 9 May 2012 14:42, Jim Meyering j...@meyering.net wrote: From 5dce6a052cdc2a45ada3e3e96a8c3ef4e90f Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Mon, 7 May 2012 18:34:26 +0200 Subject: [PATCH] linux-user: remove two unchecked uses of strdup

Re: [Qemu-devel] [PATCH 03/22] vmdk: relative_path: avoid buffer overrun

2012-05-09 Thread Jim Meyering
Kevin Wolf wrote: Am 09.05.2012 11:23, schrieb Jim Meyering: From: Jim Meyering meyer...@redhat.com strncpy does not guarantee NUL-termination. Setting dest[n-1] = '\0' *before* calling strncpy(dest, src, n-1) is a no-op. Use pstrcpy to ensure NUL-termination, not strncpy. It's

[Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Remove unnecessary and unchecked uses of strdup, and add a comment that this strncpy use is ok. Signed-off-by: Jim Meyering meyer...@redhat.com --- linux-user/elfload.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/linux

Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup

2012-05-09 Thread Jim Meyering
Peter Maydell wrote: On 9 May 2012 15:01, Jim Meyering j...@meyering.net wrote: From 402100deb7e27b1d7ac619ebac963f861fae91b0 Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Mon, 7 May 2012 18:34:26 +0200 Subject: [PATCH] linux-user: remove two unchecked uses of strdup

Re: [Qemu-devel] [PATCH 18/22] acpi: remove strzcpy (strncpy-identical) function; just use strncpy

2012-05-09 Thread Jim Meyering
Peter Maydell wrote: On 9 May 2012 10:24, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Adjust all uses s/strzcpy/strncpy/ and mark these uses of strncpy as ok. Note that this will conflict with Paolo's patch http://patchwork.ozlabs.org/patch/151895

Re: [Qemu-devel] [PATCH 13/22] virtio-9p: avoid unwarranted use of strncpy

2012-05-09 Thread Jim Meyering
Aneesh Kumar K.V wrote: Jim Meyering j...@meyering.net writes: From: Jim Meyering meyer...@redhat.com The use of strncpy in pt_listxattr is unnecessary, since we know that the NUL-terminated source bytes fit in the destination buffer. Use memcpy in place of strncpy. Signed-off-by: Jim

[Qemu-devel] [PATCH 19/22] qcow2: mark this file's sole strncpy use as justified

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- block/qcow2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qcow2.c b/block/qcow2.c index 8c60a6f..abc985e 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -990,6 +990,7 @@ int

[Qemu-devel] [PATCH 14/22] vscsi: avoid unwarranted strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Don't use strncpy when the source string is known to fit in the destination buffer. Use equivalent memcpy. We could even use strcpy, here, but some static analyzers warn about that, so don't add new uses. Signed-off-by: Jim Meyering meyer...@redhat.com

[Qemu-devel] [PATCH 11/22] virtio-9p: avoid unwarranted uses of strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com In both mp_pacl_listxattr and mp_dacl_listxattr, the uses of strncpy were unnecessary, since at each point of use we know that the NUL-terminated source bytes fit in the destination buffer. Use memcpy in place of strncpy. Signed-off-by: Jim Meyering meyer

[Qemu-devel] [PATCH 16/22] qemu-ga: prefer pstrcpy: consistently NUL-terminate ifreq.ifr_name

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com NUL-termination of the .ifr_name field is not required, but is fine (and preferable to using strncpy and leaving the reader to wonder), since the first thing the linux kernel does is to clear the last byte. Besides, using pstrcpy here makes this setting

[Qemu-devel] [PATCH 13/22] virtio-9p: avoid unwarranted use of strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com The use of strncpy in pt_listxattr is unnecessary, since we know that the NUL-terminated source bytes fit in the destination buffer. Use memcpy in place of strncpy. Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/9pfs/virtio-9p-xattr.c | 3 ++- 1

[Qemu-devel] [PATCH 12/22] virtio-9p: avoid unwarranted use of strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com The use of strncpy in mp_user_listxattr is unnecessary, since we know that the NUL-terminated source bytes fit in the destination buffer. Use memcpy in place of strncpy. Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/9pfs/virtio-9p-xattr-user.c

[Qemu-devel] [PATCH 02/22] sheepdog: avoid a few buffer overruns

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com * parse_vdiname: Use pstrcpy, not strncpy, when the destination buffer must be NUL-terminated. * sd_open: Likewise, avoid buffer overrun. * do_sd_create: Likewise. Leave the preceding memset, since pstrcpy does not NUL-fill, and filename needs

[Qemu-devel] [PATCH 10/22] bt: replace fragile snprintf use and unwarranted strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com In bt_hci_name_req a failed snprintf could return len larger than sizeof(params.name), which means the following memset call would have a length value of (size_t)-1, -2, etc... Sounds scary. But currently, one can deduce that there is no problem: strlen

[Qemu-devel] get_maintainer.pl prints invalid Cc: [Re: Fwd: Undelivered Mail Returned to Sender

2012-05-09 Thread Jim Meyering
Alexander Graf wrote: Hrm :) That appears to be due to scripts/get_maintainer.pl not sanitizing its output addresses. E.g., using my 06/22 patch, I get this bogus Cc: $ scripts/get_maintainer.pl 0006-*|grep open qemu-devel@nongnu.org (open list:POSIX) Original Message

Re: [Qemu-devel] [PATCH] qga/commands-posix.c: Fix typo in error message

2012-05-09 Thread Jim Meyering
Peter Maydell wrote: Signed-off-by: Peter Maydell peter.mayd...@linaro.org --- NB: might trivially textually conflict with Jim Meyering's strncpy fix here. (I spotted this typo in the context lines for his patch...) qga/commands-posix.c |2 +- 1 files changed, 1 insertions(+), 1

[Qemu-devel] [PATCH] fix some common typos

2012-05-09 Thread Jim Meyering
/test-mmap.c Signed-off-by: Jim Meyering meyer...@redhat.com --- Changelog | 2 +- coroutine-sigaltstack.c | 2 +- disas.c | 2 +- hw/usb/hcd-ehci.c | 4 ++-- qapi-schema-guest.json | 2 +- qemu-ga.c | 2 +- qga/commands-posix.c| 4 ++-- tests/tcg

[Qemu-devel] [PATCH 20/22] hw/r2d: add comment: this strncpy use is ok

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/r2d.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/r2d.c b/hw/r2d.c index c55de01..ed841c5 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -328,6 +328,8 @@ static void r2d_init(ram_addr_t ram_size

[Qemu-devel] [PATCH 22/22] doc: update HACKING wrt strncpy/pstrcpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Reword the section on strncpy: its NUL-filling is important in some cases. Mention that pstrcpy's signature is different. Signed-off-by: Jim Meyering meyer...@redhat.com --- HACKING | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff

[Qemu-devel] strncpy: best avoided

2012-05-09 Thread Jim Meyering
[Hmm... This was supposed to be the first in the series] Given qemu's HACKING comments, I'm sure many here have read man strncpy, where it indicates it is often not the best function to use. However, many of the uses of strncpy in qemu mistakenly fail to ensure that the destination buffer is

[Qemu-devel] strncpy: best avoided (resend)

2012-05-09 Thread Jim Meyering
[Argh. First attempt omitted the most important address: qemu-devel. Sorry to all who get two copies. ] Given qemu's HACKING comments, I'm sure many here have read man strncpy, where it indicates it is often not the best function to use. However, many of the uses of strncpy in qemu mistakenly

[Qemu-devel] [PATCH 21/22] scsi: mark an strncpy use as valid

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/scsi-bus.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index dbdb99c..916f425 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -402,6 +402,7 @@ static bool

[Qemu-devel] [PATCH 05/22] lm32: avoid buffer overrun

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Actually do what the comment says, using pstrcpy to NUL-terminate: strncpy does not always do that. Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/lm32_hwsetup.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/lm32_hwsetup.h

[Qemu-devel] [PATCH 15/22] target-i386: use pstrcpy, not strncpy

2012-05-09 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Use pstrcpy rather than strncpy in one more case (in cpudef_setfield). This makes our handling of -model_id consistent with another pstrcpy-vs-model_id use below. Signed-off-by: Jim Meyering meyer...@redhat.com --- target-i386/cpu.c | 2 +- 1 file changed

[Qemu-devel] [PATCHv2] fix some common typos

2012-05-09 Thread Jim Meyering
-mmap.c Also, manually fix arithmentic, spotted by Peter Maydell: sed -i 's!arithmentic!arithmetic!' coroutine-sigaltstack.c Signed-off-by: Jim Meyering meyer...@redhat.com --- ... Also arithmetic. Thanks. Amended. Changelog | 2 +- coroutine-sigaltstack.c | 2 +- disas.c

Re: [Qemu-devel] get_maintainer.pl prints invalid Cc: [Re: Fwd: Undelivered Mail Returned to Sender

2012-05-09 Thread Jim Meyering
Andreas Färber wrote: Am 09.05.2012 14:38, schrieb Jim Meyering: Alexander Graf wrote: Hrm :) That appears to be due to scripts/get_maintainer.pl not sanitizing its output addresses. E.g., using my 06/22 patch, I get this bogus Cc: $ scripts/get_maintainer.pl 0006-*|grep open

Re: [Qemu-devel] strncpy: best avoided (resend)

2012-05-10 Thread Jim Meyering
Kevin Wolf wrote: Am 09.05.2012 11:23, schrieb Jim Meyering: [Argh. First attempt omitted the most important address: qemu-devel. Sorry to all who get two copies. ] Given qemu's HACKING comments, I'm sure many here have read man strncpy, where it indicates it is often not the best function

[Qemu-devel] [PATCH 0/2] memset/sizeof abuse

2012-05-10 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com I ran coverity on all of qemu and have begun going through the results. A couple problems jumped out as obvious and easy to fix: Jim Meyering (2): kvm/apic: correct short memset cadence_gem: avoid stack-writing buffer-overrun hw/cadence_gem.c | 2

[Qemu-devel] [PATCH 2/2] cadence_gem: avoid stack-writing buffer-overrun

2012-05-10 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Use sizeof(rxbuf)-size (not sizeof(rxbuf-size)) as the number of bytes to clear. The latter would always clear 4 or 8 bytes, possibly writing beyond the end of that stack buffer. Alternatively, depending on the value of the size parameter, it could fail

[Qemu-devel] [PATCH 1/2] kvm/apic: correct short memset

2012-05-10 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com kvm_put_apic_state's attempt to clear *kapic before setting its bits cleared sizeof(void*) bytes (no more than 8) rather than the intended 1024 (KVM_APIC_REG_SIZE) bytes. Spotted by coverity. Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/kvm

Re: [Qemu-devel] checkpatch issue

2012-05-10 Thread Jim Meyering
. From 49f786191ab2a8176eb44a78e3d5ba44da6e10b6 Mon Sep 17 00:00:00 2001 From: Jim Meyering meyer...@redhat.com Date: Thu, 10 May 2012 18:25:51 +0200 Subject: [PATCH] . Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/usb/hcd-ehci.c | 5 + 1 file changed, 5 insertions(+) diff --git a/hw

[Qemu-devel] [PATCH] posix-aio: don't set aiocb-ret/active outside critical section

2012-05-15 Thread Jim Meyering
Move code that sets aiocb-ret and aiocb-active into critical section. All other accesses are lock-guarded. Spotted by coverity. Signed-off-by: Jim Meyering meyer...@redhat.com --- I've included enough context to show one of the guarded uses in the following function. posix-aio-compat.c | 2

Re: [Qemu-devel] [PATCH] posix-aio: don't set aiocb-ret/active outside critical section

2012-05-15 Thread Jim Meyering
Kevin Wolf wrote: Am 15.05.2012 13:27, schrieb Jim Meyering: Move code that sets aiocb-ret and aiocb-active into critical section. All other accesses are lock-guarded. Spotted by coverity. Signed-off-by: Jim Meyering meyer...@redhat.com --- I've included enough context to show one

[Qemu-devel] [PATCH 1/6] qcow2: don't leak buffer for unexpected qcow_version in header

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- block/qcow2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qcow2.c b/block/qcow2.c index 655799c..f3388bf 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -919,6 +919,7 @@ int

[Qemu-devel] [PATCH 0/6] plug memory and file-descriptor leaks

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com These changes fix most of the legitimate coverity-reported leak warnings. Jim Meyering (6): qcow2: don't leak buffer for unexpected qcow_version in header qemu-ga: avoid unconditional lockfile file descriptor leak linux-user: do_msgrcv: don't leak

[Qemu-devel] [PATCH 4/6] sheepdog: don't leak socket file descriptor upon connection failure

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- block/sheepdog.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/sheepdog.c b/block/sheepdog.c index e01d371..a5c834f 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -489,6 +489,7

[Qemu-devel] [PATCH 3/6] linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- linux-user/syscall.c | 1 + 1 file changed, 1 insertion(+) diff --git a/linux-user/syscall.c b/linux-user/syscall.c index 20d2a74..bdf8ce0 100644 --- a/linux-user/syscall.c +++ b/linux-user/syscall.c

[Qemu-devel] [PATCH 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Use g_malloc/g_free in place of malloc/free. Signed-off-by: Jim Meyering meyer...@redhat.com --- softmmu-semi.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/softmmu-semi.h b/softmmu-semi.h index 648cb95..996e0f7 100644

[Qemu-devel] [PATCH 2/6] qemu-ga: avoid unconditional lockfile file descriptor leak

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Do not leak a file descriptor. Also, do not forget to unlink the lockfile upon failed lockf. Always close the lockfile file descriptor, taking care to diagnose close, as well as open and write, failure. Signed-off-by: Jim Meyering meyer...@redhat.com

[Qemu-devel] [PATCH 5/6] arm-semi: don't leak 1kb user string lock buffer upon TARGET_SYS_OPEN

2012-05-16 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Always call unlock_user before returning. . Signed-off-by: Jim Meyering meyer...@redhat.com --- arm-semi.c | 13 +++-- 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/arm-semi.c b/arm-semi.c index 88ca9bb..5d2a2d2 100644 --- a/arm

Re: [Qemu-devel] [PATCH 3/6] linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure

2012-05-16 Thread Jim Meyering
Peter Maydell wrote: On 16 May 2012 14:07, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com ---  linux-user/syscall.c | 1 +  1 file changed, 1 insertion(+) diff --git a/linux-user/syscall.c b/linux-user

[Qemu-devel] [PATCHv2 3/6] linux-user: do_msgrcv: don't leak host_mb upon TARGET_EFAULT failure

2012-05-16 Thread Jim Meyering
Also, use g_malloc to avoid NULL-deref upon OOM. Signed-off-by: Jim Meyering meyer...@redhat.com --- There are other, similar NULL-deref risks in this file. TBD separately. linux-user/syscall.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/linux-user/syscall.c b/linux

Re: [Qemu-devel] [PATCH 2/6] qemu-ga: avoid unconditional lockfile file descriptor leak

2012-05-16 Thread Jim Meyering
Michael Roth wrote: On Wed, May 16, 2012 at 03:07:57PM +0200, Jim Meyering wrote: From: Jim Meyering meyer...@redhat.com Do not leak a file descriptor. Also, do not forget to unlink the lockfile upon failed lockf. Always close the lockfile file descriptor, taking care to diagnose close

[Qemu-devel] [PATCHv2 2/6] qemu-ga: don't leak a file descriptor upon failed lockf

2012-05-16 Thread Jim Meyering
Signed-off-by: Jim Meyering meyer...@redhat.com --- qemu-ga.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/qemu-ga.c b/qemu-ga.c index 680997e..24b236a 100644 --- a/qemu-ga.c +++ b/qemu-ga.c @@ -246,6 +246,9 @@ static bool ga_open_pidfile(const char *pidfile) pidfd = open(pidfile

[Qemu-devel] [PATCH 0/3] tighten scope of accidentally global variables

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com I noticed this commit, virtio-pci: add missing 'static' which made this change: -const MemoryRegionPortio virtio_portio[] = { +static const MemoryRegionPortio virtio_portio[] = { and wondered if there were other variables like

[Qemu-devel] [PATCH 1/3] xen: remove unused global, xen_xcg

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/xen_backend.c | 1 - 1 file changed, 1 deletion(-) diff --git a/hw/xen_backend.c b/hw/xen_backend.c index 66cb144..e44ced0 100644 --- a/hw/xen_backend.c +++ b/hw/xen_backend.c @@ -47,7 +47,6

[Qemu-devel] [PATCH 2/3] scsi: declare vmstate_info_scsi_requests to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/scsi-bus.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/scsi-bus.c b/hw/scsi-bus.c index 8ab9bcd..f10f3ec 100644 --- a/hw/scsi-bus.c +++ b/hw/scsi-bus.c @@ -1561,7 +1561,7

[Qemu-devel] [PATCH 3/3] qemu-config: qemu_option_rom_opts, qemu_boot_opts: declare static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- qemu-config.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/qemu-config.c b/qemu-config.c index be84a03..c03e52b 100644 --- a/qemu-config.c +++ b/qemu-config.c @@ -528,7 +528,7

Re: [Qemu-devel] [PATCH 1/3] envlist.c: handle strdup failure

2012-05-21 Thread Jim Meyering
Blue Swirl wrote: On Tue, May 15, 2012 at 1:04 PM, j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Without this, envlist_to_environ may silently fail to copy all strings into the destination buffer, and both callers would leak any env strings allocated after a failing strdup

[Qemu-devel] [PATCHv2 1/6] qcow2: don't leak buffer for unexpected qcow_version in header

2012-05-21 Thread Jim Meyering
Signed-off-by: Jim Meyering meyer...@redhat.com --- Thanks to Kevin Wolf for the improvement. block/qcow2.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/block/qcow2.c b/block/qcow2.c index 655799c..c2e49cd 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -919,7 +919,8

Re: [Qemu-devel] [PATCH 1/6] qcow2: don't leak buffer for unexpected qcow_version in header

2012-05-21 Thread Jim Meyering
Kevin Wolf wrote: Am 16.05.2012 15:07, schrieb Jim Meyering: From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- block/qcow2.c | 1 + 1 file changed, 1 insertion(+) diff --git a/block/qcow2.c b/block/qcow2.c index 655799c..f3388bf 100644

Re: [Qemu-devel] [PATCH 0/3] tighten scope of accidentally global variables

2012-05-21 Thread Jim Meyering
Blue Swirl wrote: On Mon, May 21, 2012 at 10:03 AM, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com I noticed this commit,    virtio-pci: add missing 'static' which made this change:     -const MemoryRegionPortio virtio_portio[] = {     +static const

Re: [Qemu-devel] [PATCH 0/3] tighten scope of accidentally global variables

2012-05-21 Thread Jim Meyering
Blue Swirl wrote: On Mon, May 21, 2012 at 6:10 PM, Jim Meyering j...@meyering.net wrote: Blue Swirl wrote: On Mon, May 21, 2012 at 10:03 AM, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com I noticed this commit,    virtio-pci: add missing 'static' which made

[Qemu-devel] [PATCH 0/9] convert many more globals to static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Following up on discussion here, http://marc.info/?t=13375948768r=1w=2 here are patches to limit the scope of the remaining global variables. Most changes simply added a preceding static. However, in some cases, I've made minor additional changes

[Qemu-devel] [PATCH 1/9] ccid: declare DEFAULT_ATR table to be static const

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/ccid-card-passthru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index bd6c777..1caaa45 100644 --- a/hw/ccid-card-passthru.c

[Qemu-devel] [PATCH 1/9] ccid: declare DEFAULT_ATR table to be static const

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/ccid-card-passthru.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ccid-card-passthru.c b/hw/ccid-card-passthru.c index bd6c777..1caaa45 100644 --- a/hw/ccid-card-passthru.c

[Qemu-devel] [PATCH 2/9] tcg: declare __jit_debug_descriptor to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- tcg/tcg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index ab589c7..350fdad 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2293,7 +2293,7 @@ void

[Qemu-devel] [PATCH 2/9] tcg: declare __jit_debug_descriptor to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- tcg/tcg.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index ab589c7..350fdad 100644 --- a/tcg/tcg.c +++ b/tcg/tcg.c @@ -2293,7 +2293,7 @@ void

[Qemu-devel] [PATCH 3/9] alpha-dis: remove unused global; declare others to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com alpha_num_operands: Remove both declarations of this unused global. alpha_opcodes: Declare static to limit scope. Remove duplicate decl. alpha_num_opcodes: Likewise. alpha_operands: Likewise. Signed-off-by: Jim Meyering meyer...@redhat.com --- alpha-dis.c

[Qemu-devel] [PATCH 3/9] alpha-dis: remove unused global; declare others to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com alpha_num_operands: Remove both declarations of this unused global. alpha_opcodes: Declare static to limit scope. Remove duplicate decl. alpha_num_opcodes: Likewise. alpha_operands: Likewise. Signed-off-by: Jim Meyering meyer...@redhat.com --- alpha-dis.c

[Qemu-devel] [PATCH 6/9] sheepdog: declare bdrv_sheepdog to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- block/sheepdog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/sheepdog.c b/block/sheepdog.c index e01d371..fdb3eca 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c

[Qemu-devel] [PATCH 4/9] linux-user: arg_table need not have global scope

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Declare arg_table to be static const, and adjust the two users to also be const. Signed-off-by: Jim Meyering meyer...@redhat.com --- linux-user/main.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/linux-user/main.c b/linux-user

[Qemu-devel] [PATCH 8/9] bonito: declare bonito_state to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/bonito.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/bonito.c b/hw/bonito.c index 77786f8..6bd0242 100644 --- a/hw/bonito.c +++ b/hw/bonito.c @@ -218,7 +218,7 @@ typedef

[Qemu-devel] [PATCH 5/9] ccid: make backend_enum_table static const and adjust users

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/ccid-card-emulated.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/hw/ccid-card-emulated.c b/hw/ccid-card-emulated.c index f4a6da4..440f050 100644 --- a/hw/ccid-card

Re: [Qemu-devel] [PATCH 2/9] tcg: declare __jit_debug_descriptor to be static

2012-05-21 Thread Jim Meyering
Peter Maydell wrote: On 21 May 2012 20:51, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com ---  tcg/tcg.c | 2 +-  1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tcg/tcg.c b/tcg/tcg.c index ab589c7

[Qemu-devel] [PATCH 7/9] mips-dis: declare four globals to be static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- mips-dis.c | 15 +++ 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/mips-dis.c b/mips-dis.c index e3a6e0b..f6109a1 100644 --- a/mips-dis.c +++ b/mips-dis.c @@ -888,10 +888,9

[Qemu-devel] [PATCH 9/9] convert many more globals to static

2012-05-21 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Minor exceptions: * arm-dis: move now-detected-as-unused static variables into #if-0'd block of code where they *are* used. * microblaze: remove decls of now-detected-as-unused vars Signed-off-by: Jim Meyering meyer...@redhat.com --- arm-dis.c

[Qemu-devel] [PATCH 0/2] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Per discussion, let's switch envlist.c to indent with spaces, and then make the fix: Jim Meyering (2): envlist.c: convert many leading TABs to spaces via expand -i envlist.c: handle strdup failure envlist.c | 272

[Qemu-devel] [PATCH 1/2] envlist.c: convert many leading TABs to spaces via expand -i

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- envlist.c | 256 +++--- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/envlist.c b/envlist.c index f2303cd..1d98108 100644

[Qemu-devel] [PATCH 2/2] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Without this, envlist_to_environ may silently fail to copy all strings into the destination buffer, and both callers would leak any env strings allocated after a failing strdup, because the freeing code stops at the first NULL pointer. Signed-off-by: Jim

Re: [Qemu-devel] [PATCH 1/3] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
Kevin Wolf wrote: A patch replacing tabs by spaces isn't really the kind of patches that we would want to avoid during freeze. It's easy enough to check with git diff -w that it doesn't change anything semantically. That makes sense, so I've posted two patches: 1) two patches: one

[Qemu-devel] [PATCHv2 0/2] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com This is the same as v1, except that two lines of non-leading TABs in envlist.c (indenting comments after code) have also been converted to use equivalent spaces instead of TABs. Jim Meyering (2): envlist.c: convert all TABs to equivalent spaces

[Qemu-devel] [PATCHv2 2/2] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Without this, envlist_to_environ may silently fail to copy all strings into the destination buffer, and both callers would leak any env strings allocated after a failing strdup, because the freeing code stops at the first NULL pointer. Signed-off-by: Jim

[Qemu-devel] [PATCHv2 1/2] envlist.c: convert all TABs to equivalent spaces

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- envlist.c | 256 +++--- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/envlist.c b/envlist.c index f2303cd..be0addb 100644

Re: [Qemu-devel] [PATCH 1/3] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
Kevin Wolf wrote: Am 22.05.2012 11:05, schrieb Jim Meyering: Kevin Wolf wrote: A patch replacing tabs by spaces isn't really the kind of patches that we would want to avoid during freeze. It's easy enough to check with git diff -w that it doesn't change anything semantically. That makes

[Qemu-devel] [PATCHv3 0/2] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Same as v2, but now with TABs converted using expand --tabs=4. Jim Meyering (2): envlist.c: convert each TAB(width-4) to equivalent spaces envlist.c: handle strdup failure envlist.c | 272

[Qemu-devel] [PATCHv3 1/2] envlist.c: convert each TAB(width-4) to equivalent spaces

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- envlist.c | 256 +++--- 1 file changed, 128 insertions(+), 128 deletions(-) diff --git a/envlist.c b/envlist.c index f2303cd..e44889b 100644

[Qemu-devel] [PATCHv2 2/9] tcg: __jit_debug_descriptor must *not* be static

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Add comments so no one else will be tempted to reduce the scope of this global variable. Signed-off-by: Jim Meyering meyer...@redhat.com --- tcg/tcg.c | 10 +++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/tcg/tcg.c b/tcg/tcg.c

Re: [Qemu-devel] [PATCH 2/9] tcg: declare __jit_debug_descriptor to be static

2012-05-22 Thread Jim Meyering
Peter Maydell wrote: On 21 May 2012 21:10, Jim Meyering j...@meyering.net wrote: Peter Maydell wrote: On 21 May 2012 20:51, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com ---  tcg/tcg.c | 2 +-  1 file changed

Re: [Qemu-devel] [PATCHv2 1/2] envlist.c: convert all TABs to equivalent spaces

2012-05-22 Thread Jim Meyering
Peter Maydell wrote: On 22 May 2012 10:50, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com If we're going to go to the effort of a complete reindent patch we should actually reindent to the QEMU coding style standard, which is four-space, not eight. Good point

[Qemu-devel] [PATCHv3 2/2] envlist.c: handle strdup failure

2012-05-22 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Without this, envlist_to_environ may silently fail to copy all strings into the destination buffer, and both callers would leak any env strings allocated after a failing strdup, because the freeing code stops at the first NULL pointer. Signed-off-by: Jim

[Qemu-devel] [PATCH v2 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM

2012-05-24 Thread Jim Meyering
Return NULL upon malloc failure. Signed-off-by: Jim Meyering meyer...@redhat.com --- Improved based on suggestion from Peter Maydell: Handle malloc failure rather than relying on g_malloc, since we can't afford to let guest-provided len induce g_malloc's abort. softmmu-semi.h | 5 - 1 file

Re: [Qemu-devel] [PATCH 6/6] softmmu-semi: fix lock_user* functions not to deref NULL upon OOM

2012-05-24 Thread Jim Meyering
Peter Maydell wrote: On 16 May 2012 14:08, Jim Meyering j...@meyering.net wrote: From: Jim Meyering meyer...@redhat.com Use g_malloc/g_free in place of malloc/free. Signed-off-by: Jim Meyering meyer...@redhat.com ---  softmmu-semi.h | 6 +++---  1 file changed, 3 insertions(+), 3

[Qemu-devel] [PATCH] block: prevent snapshot mode $TMPDIR symlink attack

2012-05-28 Thread Jim Meyering
-2652. http://bugzilla.redhat.com/CVE-2012-2652 Signed-off-by: Jim Meyering meyer...@redhat.com --- Note that I haven't tried to see if the _WIN32 -GetLastError() return value is properly diagnosed as it is propagated up the call stack. block.c | 37

Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup

2012-05-30 Thread Jim Meyering
Anthony Liguori wrote: On 05/09/2012 10:12 PM, Jim Meyering wrote: Peter Maydell wrote: On 9 May 2012 15:01, Jim Meyeringj...@meyering.net wrote: From 402100deb7e27b1d7ac619ebac963f861fae91b0 Mon Sep 17 00:00:00 2001 From: Jim Meyeringmeyer...@redhat.com Date: Mon, 7 May 2012 18:34:26

[Qemu-devel] [PATCHv2 03/22] block: avoid buffer overrun by using pstrcpy, not strncpy

2012-05-30 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Also, use PATH_MAX, rather than the arbitrary 1024. Using PATH_MAX is more consistent with other filename-related variables in this file, like backing_filename and tmp_filename. Acked-by: Kevin Wolf kw...@redhat.com Signed-off-by: Jim Meyering meyer

[Qemu-devel] [PATCHv2 20/22] hw/r2d: add comment: this strncpy use is ok

2012-05-30 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com Signed-off-by: Jim Meyering meyer...@redhat.com --- hw/r2d.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/r2d.c b/hw/r2d.c index c55de01..ed841c5 100644 --- a/hw/r2d.c +++ b/hw/r2d.c @@ -328,6 +328,8 @@ static void r2d_init(ram_addr_t ram_size

Re: [Qemu-devel] [PATCH 08/22] linux-user: remove two unchecked uses of strdup

2012-05-30 Thread Jim Meyering
Anthony Liguori wrote: On 05/30/2012 03:12 PM, Jim Meyering wrote: Anthony Liguori wrote: On 05/09/2012 10:12 PM, Jim Meyering wrote: Peter Maydell wrote: On 9 May 2012 15:01, Jim Meyeringj...@meyering.net wrote: From 402100deb7e27b1d7ac619ebac963f861fae91b0 Mon Sep 17 00:00:00 2001

[Qemu-devel] [PATCHv2 09/22] ppc: avoid buffer overrun: use pstrcpy, not strncpy

2012-05-30 Thread Jim Meyering
From: Jim Meyering meyer...@redhat.com A terminal NUL is required by caller's use of strchr. It's better not to use strncpy at all, since there is no need to zero out hundreds of trailing bytes for each iteration. Signed-off-by: Jim Meyering meyer...@redhat.com --- target-ppc/kvm.c | 2 +- 1

  1   2   >