summaryrefslogtreecommitdiff
path: root/source3/rpc_server
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-07-30 15:39:38 +0200
committerJeremy Allison <jra@samba.org>2019-08-08 20:24:32 +0000
commit25c5012c53f4d8efbe04ee8d3c8af256fec592a7 (patch)
treec551d873b99150e81b073601bae10fbf60251306 /source3/rpc_server
parent9e706ee5737bffd6f0a699ce68a75bbd0f7fd7dd (diff)
downloadsamba-25c5012c53f4d8efbe04ee8d3c8af256fec592a7.tar.gz
s3:mdssvc: avoid strncpy when marshalling strings
Avoids failure when at O3 level: [2082/4232] Compiling source3/rpc_server/mdssvc/marshalling.c ==> /builds/samba-team/devel/samba/samba-o3.stderr <== In file included from /usr/include/string.h:494, from /usr/include/bsd/string.h:30, from ../../lib/tevent/../replace/replace.h:164, from ../../source3/include/includes.h:23, from ../../source3/rpc_server/mdssvc/marshalling.c:21: In function ‘strncpy’, inlined from ‘sl_pack_string’ at ../../source3/rpc_server/mdssvc/marshalling.c:493:2, inlined from ‘sl_pack_loop’ at ../../source3/rpc_server/mdssvc/marshalling.c:607:13: /usr/include/bits/string_fortified.h:106:10: error: ‘__builtin_strncpy’ output truncated before terminating nul copying as many bytes from a string as its length [-Werror=stringop-truncation] 106 | return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ../../source3/rpc_server/mdssvc/marshalling.c: In function ‘sl_pack_loop’: ../../source3/rpc_server/mdssvc/marshalling.c:458:8: note: length computed here 458 | len = strlen(s); | ^~~~~~~~~ cc1: all warnings being treated as errors Marshalled strings are not 0 terminated. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/rpc_server')
-rw-r--r--source3/rpc_server/mdssvc/marshalling.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/source3/rpc_server/mdssvc/marshalling.c b/source3/rpc_server/mdssvc/marshalling.c
index b5931c7f060..eee1cd93010 100644
--- a/source3/rpc_server/mdssvc/marshalling.c
+++ b/source3/rpc_server/mdssvc/marshalling.c
@@ -490,7 +490,7 @@ static ssize_t sl_pack_string(char *s, char *buf, ssize_t offset, size_t bufsize
}
memset(buf + offset, 0, octets * 8);
- strncpy(buf + offset, s, len);
+ memcpy(buf + offset, s, len);
offset += octets * 8;
return offset;