libcli: Add an overflow check
authorVolker Lendecke <vl@samba.org>
Wed, 18 Jan 2017 15:43:56 +0000 (16:43 +0100)
committerJeremy Allison <jra@samba.org>
Mon, 23 Jan 2017 21:46:13 +0000 (22:46 +0100)
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
libcli/security/util_sid.c

index 2ab47f2db2c1477366a791ec8d73686eac3d2bb7..ac4487657770d9c6ea346c1fbe18674526bd792f 100644 (file)
@@ -339,6 +339,10 @@ NTSTATUS add_sid_to_array(TALLOC_CTX *mem_ctx, const struct dom_sid *sid,
 {
        struct dom_sid *tmp;
 
+       if ((*num) == UINT32_MAX) {
+               return NT_STATUS_INTEGER_OVERFLOW;
+       }
+
        tmp = talloc_realloc(mem_ctx, *sids, struct dom_sid, (*num)+1);
        if (tmp == NULL) {
                *num = 0;