diff options
author | Andreas Schneider <asn@samba.org> | 2018-05-15 17:55:22 +0200 |
---|---|---|
committer | Andreas Schneider <asn@cryptomilk.org> | 2018-05-17 17:30:09 +0200 |
commit | 609ef35c12900bbd5ecaa557f7b5d71b5784a103 (patch) | |
tree | 367993c0e559871d6e54a064758a8c57e55b53ef /source4/ntvfs | |
parent | fb6cd9c44ac6fcc9f6abe3b63fc742aeac42969a (diff) | |
download | samba-609ef35c12900bbd5ecaa557f7b5d71b5784a103.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>
Diffstat (limited to 'source4/ntvfs')
-rw-r--r-- | source4/ntvfs/ipc/rap_server.c | 9 |
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, ""); |