]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
ntvfs: Simplify rap_netshareenum()
authorVolker Lendecke <vl@samba.org>
Thu, 17 Mar 2022 18:31:44 +0000 (19:31 +0100)
committerJeremy Allison <jra@samba.org>
Wed, 5 Feb 2025 01:05:07 +0000 (01:05 +0000)
I know, unused. But the whole point of strlcpy is that we don't need
this kind of calculation, and we should not leave this as a bad
example code in our tree.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Feb  5 01:05:08 UTC 2025 on atb-devel-224

source4/ntvfs/ipc/rap_server.c

index 4c4beca13332304e8c8728c585d7435c86a2b38f..6c2a187c12581fda25aab327c409a13a3f874c71 100644 (file)
@@ -62,18 +62,14 @@ NTSTATUS rap_netshareenum(TALLOC_CTX *mem_ctx,
                                   union rap_share_info, r->out.available);
 
        for (i = 0, j = 0; i < r->out.available; i++) {
-               size_t sname_len;
 
                if (!NT_STATUS_IS_OK(share_get_config(mem_ctx, sctx, snames[i], &scfg))) {
                        DEBUG(3, ("WARNING: Service [%s] disappeared after enumeration!\n", snames[i]));
                        continue;
                }
-               /* Make sure we have NUL-termination */
-               sname_len = MIN(strlen(snames[i]),
-                               sizeof(r->out.info[j].info1.share_name));
                strlcpy((char *)r->out.info[j].info1.share_name,
                        snames[i],
-                       sname_len);
+                       sizeof(r->out.info[j].info1.share_name));
                r->out.info[i].info1.reserved1 = 0;
                r->out.info[i].info1.share_type = dcesrv_common_get_share_type(mem_ctx, NULL, scfg);
                r->out.info[i].info1.comment = share_string_option(mem_ctx, scfg, SHARE_COMMENT, "");