]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
lib:ldb:tools: Do not leak memory in ldb_cmdline_process_internal()
authorAndreas Schneider <asn@samba.org>
Wed, 22 Oct 2025 07:33:56 +0000 (09:33 +0200)
committerAndreas Schneider <asn@cryptomilk.org>
Wed, 22 Oct 2025 09:25:35 +0000 (09:25 +0000)
If add_control() hasn't been called before, it will be NULL. Use ret as
the context to allocate memory on.

Direct leak of 110 byte(s) in 1 object(s) allocated from:
    #0 0x7fc1b5921c2b in malloc (/lib64/libasan.so.8+0x121c2b) (BuildId: 388ee9ac193f74c177c6f52988d2d0dab110de41)
    #1 0x7fc1b56ed6a0 in __talloc_with_prefix ../../lib/talloc/talloc.c:783
    #2 0x7fc1b56ee9e8 in __talloc ../../lib/talloc/talloc.c:825
    #3 0x7fc1b56ee9e8 in __talloc_strlendup ../../lib/talloc/talloc.c:2454
    #4 0x7fc1b56ee9e8 in talloc_strdup ../../lib/talloc/talloc.c:2470
    #5 0x7fc1b5f1ad18 in ldb_cmdline_process_internal ../../lib/ldb/tools/cmdline.c:389
    #6 0x7fc1b5f1b53c in ldb_cmdline_process ../../lib/ldb/tools/cmdline.c:544
    #7 0x000000202a19 in main ../../lib/ldb/tools/ldbdel.c:97
    #8 0x7fc1b542b2fa in __libc_start_call_main (/lib64/libc.so.6+0x2b2fa) (BuildId: 8523b213e7586a93ab00f6dd476418b1e521e62c)
    #9 0x7ffdced96847  ([stack]+0x38847)

Signed-off-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Noel Power <npower@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Wed Oct 22 09:25:35 UTC 2025 on atb-devel-224

lib/ldb/tools/cmdline.c

index a6d51dffc9299f69f2bdbfbe9f31f6c7a064d1f6..4f6068b985f183b567e6fbfbe6259bec5a17f596 100644 (file)
@@ -386,10 +386,10 @@ static struct ldb_cmdline *ldb_cmdline_process_internal(struct ldb_context *ldb,
 
                                t = strchr(p, ',');
                                if (t == NULL) {
-                                       c = talloc_strdup(options.controls, p);
+                                       c = talloc_strdup(ret, p);
                                        p = NULL;
                                } else {
-                                       c = talloc_strndup(options.controls, p, t-p);
+                                       c = talloc_strndup(ret, p, t-p);
                                        p = t + 1;
                                }
                                if (c == NULL || !add_control(ret, c)) {