pypamtest: Add sanity checks in new_conv_list()
authorAndreas Schneider <asn@samba.org>
Thu, 6 Apr 2017 07:13:40 +0000 (09:13 +0200)
committerAndreas Schneider <asn@samba.org>
Thu, 6 Apr 2017 07:20:23 +0000 (09:20 +0200)
Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
src/python/pypamtest.c

index 2a2f7c48679c622449c7cce2f9dcfa46b224056c..585f27d0f110fbbe6c79af356eab3178c209ba7c 100644 (file)
@@ -133,10 +133,18 @@ static void free_string_list(char **list)
        PyMem_Free(list);
 }
 
-static char **new_conv_list(const int list_size)
+static char **new_conv_list(const size_t list_size)
 {
        char **list;
-       int i;
+       size_t i;
+
+       if (list_size == 0) {
+               return NULL;
+       }
+
+       if (list_size + 1 < list_size) {
+               return NULL;
+       }
 
        list = PyMem_New(char *, list_size + 1);
        if (list == NULL) {