Fix keylist signed integer wraparound (#179)

* Fix keylist signed integer wraparound

Fix the keylist to handle large number of nodes where the signed integer
would wrap around.

* Add explict keylist new size case for less than zero

Co-authored-by: Steve Karg <skarg@users.sourceforge.net>
Co-authored-by: Steve Karg <steve.karg@legrand.us>
This commit is contained in:
Steve Karg
2021-06-12 22:37:51 -05:00
committed by GitHub
parent 89d7af707e
commit 31b7fb3c40
+4 -1
View File
@@ -101,7 +101,7 @@ static int CheckArraySize(OS_Keylist list)
} else if ((list->size > chunk) && (list->count < (list->size - chunk))) {
new_size = list->size - chunk;
}
if (new_size) {
if (new_size > 0) {
/* Allocate more room for node pointer array */
new_array = calloc((size_t)new_size, sizeof(struct Keylist_Node *));
@@ -119,7 +119,10 @@ static int CheckArraySize(OS_Keylist list)
}
list->array = new_array;
list->size = new_size;
} else if (new_size < 0) {
return FALSE;
}
return TRUE;
}