From ce49cfb48ad5e9cac79819d0ccde4394c237af25 Mon Sep 17 00:00:00 2001 From: Eric Blake Date: Wed, 2 Jun 2010 09:03:57 -0600 Subject: [PATCH] bitmap: reject zero-size bitmap * src/util/bitmap.c (virBitmapAlloc): Tighten sanity check. --- src/util/bitmap.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/util/bitmap.c b/src/util/bitmap.c index 69094a5ffc..44edb4934e 100644 --- a/src/util/bitmap.c +++ b/src/util/bitmap.c @@ -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) /