]> xenbits.xensource.com Git - libvirt.git/commitdiff
bitmap: reject zero-size bitmap
authorEric Blake <eblake@redhat.com>
Wed, 2 Jun 2010 15:03:57 +0000 (09:03 -0600)
committerEric Blake <eblake@redhat.com>
Wed, 2 Jun 2010 15:03:57 +0000 (09:03 -0600)
* src/util/bitmap.c (virBitmapAlloc): Tighten sanity check.

src/util/bitmap.c

index 69094a5ffce6ac313e09099b08d16bbe7734bcae..44edb4934ed0f7a5a39991af1fa177129482770a 100644 (file)
@@ -1,6 +1,7 @@
 /*
  * bitmap.h: Simple bitmap operations
  *
+ * Copyright (C) 2010 Red Hat, Inc.
  * Copyright (C) 2010 Novell, Inc.
  *
  * This library is free software; you can redistribute it and/or
@@ -58,7 +59,7 @@ virBitmapPtr virBitmapAlloc(size_t size)
     virBitmapPtr bitmap;
     size_t sz;
 
-    if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size)
+    if (SIZE_MAX - VIR_BITMAP_BITS_PER_UNIT < size || size == 0)
         return NULL;
 
     sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) /