summaryrefslogtreecommitdiff
path: root/source4/ntvfs
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-05-15 17:55:22 +0200
committerKarolin Seeger <kseeger@samba.org>2018-06-20 09:22:24 +0200
commitfd836721cf2a3d4e08f7fa6486aa98c306a6f8cb (patch)
treebc90d544b95881499789c245fb1ac0039b5f7d64 /source4/ntvfs
parent15c13f7372ca6c980d38a3be83225eb3cfd18f21 (diff)
downloadsamba-fd836721cf2a3d4e08f7fa6486aa98c306a6f8cb.tar.gz
s4:ntvfs: Fix string copy of share_name
../source4/ntvfs/ipc/rap_server.c:70:3: error: ‘strncpy’ specified bound 13 equals destination size [-Werror=stringop-truncation] strncpy((char *)r->out.info[j].info1.share_name, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ snames[i], ~~~~~~~~~~ sizeof(r->out.info[0].info1.share_name)); ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> (cherry picked from commit 609ef35c12900bbd5ecaa557f7b5d71b5784a103)
Diffstat (limited to 'source4/ntvfs')
-rw-r--r--source4/ntvfs/ipc/rap_server.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/source4/ntvfs/ipc/rap_server.c b/source4/ntvfs/ipc/rap_server.c
index 3a133f568da..fc2d3aa611d 100644
--- a/source4/ntvfs/ipc/rap_server.c
+++ b/source4/ntvfs/ipc/rap_server.c
@@ -63,13 +63,18 @@ 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;
}
- strncpy((char *)r->out.info[j].info1.share_name,
+ /* 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],
- sizeof(r->out.info[0].info1.share_name));
+ sname_len);
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, "");