mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
bitmap: reject zero-size bitmap
* src/util/bitmap.c (virBitmapAlloc): Tighten sanity check.
This commit is contained in:
parent
fa6da6608a
commit
ce49cfb48a
@ -1,6 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* bitmap.h: Simple bitmap operations
|
* bitmap.h: Simple bitmap operations
|
||||||
*
|
*
|
||||||
|
* Copyright (C) 2010 Red Hat, Inc.
|
||||||
* Copyright (C) 2010 Novell, Inc.
|
* Copyright (C) 2010 Novell, Inc.
|
||||||
*
|
*
|
||||||
* This library is free software; you can redistribute it and/or
|
* This library is free software; you can redistribute it and/or
|
||||||
@ -58,7 +59,7 @@ virBitmapPtr virBitmapAlloc(size_t size)
|
|||||||
virBitmapPtr bitmap;
|
virBitmapPtr bitmap;
|
||||||
size_t sz;
|
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;
|
return NULL;
|
||||||
|
|
||||||
sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) /
|
sz = (size + VIR_BITMAP_BITS_PER_UNIT - 1) /
|
||||||
|
Loading…
Reference in New Issue
Block a user