]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
libsmb: Slightly simplify SMBC_parse_path()
authorVolker Lendecke <vl@samba.org>
Wed, 17 Aug 2022 10:03:35 +0000 (12:03 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 26 Aug 2022 18:54:37 +0000 (18:54 +0000)
Don't manually duplicate the talloc_strndup() functionality

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/libsmb/libsmb_path.c

index 73dc374d6a87ecf0df2f9b0f843febbd1d366862..9d4599acf5781b437a87e8da96fd2277743bad44 100644 (file)
@@ -287,17 +287,11 @@ SMBC_parse_path(TALLOC_CTX *ctx,
        }
 
        if (*p == '/') {
-               int wl = strlen(smbc_getWorkgroup(context));
-
-               if (wl > 16) {
-                       wl = 16;
-               }
-
-               *pp_server = talloc_strdup(ctx, smbc_getWorkgroup(context));
+               *pp_server = talloc_strndup(
+                       ctx, smbc_getWorkgroup(context), 16);
                if (!*pp_server) {
                        return -1;
                }
-               (*pp_server)[wl] = '\0';
                return 0;
        }