Re: [libvirt] [PATCH] virDomainMemoryStats: avoid null dereference

2011-02-15 Thread Eric Blake
On 02/14/2011 05:38 PM, Laine Stump wrote:
 On 02/14/2011 06:25 PM, Eric Blake wrote:
 * src/libvirt.c (virDomainMemoryStats): Check domain before flags.
 ---

 Another valid bug found by clang.  User's generally should't call
 virDomainMemoryStats(NULL,...), but we don't forbid it elsewhere, and
 doing so is not supposed to crash libvirt.  All other flags checks in
 this file occur after validating the object first.
 
 ACK

Thanks; pushed.

Wow - that actually caused a SHA1 hash collision in git that requires 8
hex digits to resolve (compared to the usual 7 or less)!

-- 
Eric Blake   ebl...@redhat.com+1-801-349-2682
Libvirt virtualization library http://libvirt.org



signature.asc
Description: OpenPGP digital signature
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Re: [libvirt] [PATCH] virDomainMemoryStats: avoid null dereference

2011-02-14 Thread Laine Stump

On 02/14/2011 06:25 PM, Eric Blake wrote:

* src/libvirt.c (virDomainMemoryStats): Check domain before flags.
---

Another valid bug found by clang.  User's generally should't call
virDomainMemoryStats(NULL,...), but we don't forbid it elsewhere, and
doing so is not supposed to crash libvirt.  All other flags checks in
this file occur after validating the object first.

  src/libvirt.c |   12 ++--
  1 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/libvirt.c b/src/libvirt.c
index 479a9b5..f65cc24 100644
--- a/src/libvirt.c
+++ b/src/libvirt.c
@@ -4411,12 +4411,6 @@ int virDomainMemoryStats (virDomainPtr dom, 
virDomainMemoryStatPtr stats,

  VIR_DOMAIN_DEBUG(dom, stats=%p, nr_stats=%u, stats, nr_stats);

-if (flags != 0) {
-virLibDomainError(VIR_ERR_INVALID_ARG,
-   _(flags must be zero));
-goto error;
-}
-
  virResetLastError();

  if (!VIR_IS_CONNECTED_DOMAIN (dom)) {
@@ -4424,6 +4418,12 @@ int virDomainMemoryStats (virDomainPtr dom, 
virDomainMemoryStatPtr stats,
  virDispatchError(NULL);
  return -1;
  }
+if (flags != 0) {
+virLibDomainError(VIR_ERR_INVALID_ARG,
+   _(flags must be zero));
+goto error;
+}
+
  if (!stats || nr_stats == 0)
  return 0;



ACK

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list