]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libcli/security: Fix leak on reallocation failure in conditional_ace_encode_binary()
authorJoseph Sutton <josephsutton@catalyst.net.nz>
Wed, 20 Sep 2023 03:04:14 +0000 (15:04 +1200)
committerAndrew Bartlett <abartlet@samba.org>
Wed, 25 Oct 2023 22:23:37 +0000 (22:23 +0000)
Signed-off-by: Joseph Sutton <josephsutton@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
libcli/security/conditional_ace.c

index 7f4766ed135962c8e345ebc27398ed693b2b1b8b..a0c9a0ccbd1ace8d132ae710119421506d681cc9 100644 (file)
@@ -2042,6 +2042,7 @@ bool conditional_ace_encode_binary(TALLOC_CTX *mem_ctx,
 {
        size_t i, j, alloc_size, required_size;
        uint8_t *data = NULL;
+       uint8_t *new_data = NULL;
        *dest = (DATA_BLOB){NULL, 0};
 
        alloc_size = CONDITIONAL_ACE_MAX_LENGTH;
@@ -2165,13 +2166,14 @@ bool conditional_ace_encode_binary(TALLOC_CTX *mem_ctx,
                data[j] = 0;
                j++;
        }
-       data = talloc_realloc(mem_ctx,
-                             data,
-                             uint8_t,
-                             required_size);
-       if (data == NULL) {
-               return false;
+       new_data = talloc_realloc(mem_ctx,
+                                 data,
+                                 uint8_t,
+                                 required_size);
+       if (new_data == NULL) {
+               goto error;
        }
+       data = new_data;
 
        (*dest).data = data;
        (*dest).length = j;