]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
winbindd: Simplify parse_domain_user()
authorVolker Lendecke <vl@samba.org>
Mon, 25 Aug 2025 10:59:32 +0000 (12:59 +0200)
committerVolker Lendecke <vl@samba.org>
Tue, 2 Sep 2025 09:08:59 +0000 (09:08 +0000)
We have talloc_strndup() for this.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Anoop C S <anoopcs@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Tue Sep  2 09:08:59 UTC 2025 on atb-devel-224

source3/winbindd/winbindd_util.c

index 174ebcbdc3d031fbce670fa8d72564ce94ade196..f7b68929bc912c8bc9645623223f353215a01740 100644 (file)
@@ -2005,12 +2005,10 @@ bool parse_domain_user(TALLOC_CTX *ctx,
                if (user == NULL) {
                        goto fail;
                }
-               domain = talloc_strdup(ctx,
-                               domuser);
+               domain = talloc_strndup(ctx, domuser, p - domuser);
                if (domain == NULL) {
                        goto fail;
                }
-               domain[PTR_DIFF(p, domuser)] = '\0';
                namespace = talloc_strdup(ctx, domain);
                if (namespace == NULL) {
                        goto fail;