lib: Fix memalign_array overflow protection
authorVolker Lendecke <vl@samba.org>
Wed, 18 Nov 2015 12:13:57 +0000 (13:13 +0100)
committerVolker Lendecke <vl@samba.org>
Thu, 19 Nov 2015 09:05:08 +0000 (10:05 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Thu Nov 19 10:05:08 CET 2015 on sn-devel-104

lib/util/util.c

index d8a84dab6d21375c38d490d4eb35c155572219f7..03edd7f7761571c915e9ee1907dd809a7ab54263 100644 (file)
@@ -773,7 +773,7 @@ void *malloc_array(size_t el_size, unsigned int count)
 
 void *memalign_array(size_t el_size, size_t align, unsigned int count)
 {
-       if (count*el_size >= MAX_MALLOC_SIZE) {
+       if (el_size == 0 || count >= MAX_MALLOC_SIZE/el_size) {
                return NULL;
        }