>From 1a0c749b20eb35ac1abdc647cb119602e4b3fb69 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 1 Nov 2016 13:26:11 +1300 Subject: [PATCH 1/4] lib/replace tests: prevent GCC fretting over snprintf sizes These tests deliberately use snprintf for truncating strings, which is fine for tests. This has the effect of leaving the warning in place but preventing it from becoming a fatal error. Signed-off-by: Douglas Bagnall --- lib/replace/wscript | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/replace/wscript b/lib/replace/wscript index 1dfd902..6565b00 100644 --- a/lib/replace/wscript +++ b/lib/replace/wscript @@ -704,9 +704,10 @@ def build(bld): deps='crypt dl nsl socket rt attr' + extra_libs) bld.SAMBA_SUBSYSTEM('replace-test', - source='''test/testsuite.c test/strptime.c - test/os2_delete.c test/getifaddrs.c''', - deps='replace') + source='''test/testsuite.c test/strptime.c + test/os2_delete.c test/getifaddrs.c''', + deps='replace', + cflags="-Wformat-length") if bld.env.standalone_replace: bld.SAMBA_BINARY('replace_testsuite', -- 2.7.4 >From 48f64985e83e1fe957eac98a1564135fb63ff6e0 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 1 Nov 2016 13:27:16 +1300 Subject: [PATCH 2/4] vfs_shadow_copy: avoid GCC qualms over snprintf length --- source3/modules/wscript_build | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source3/modules/wscript_build b/source3/modules/wscript_build index a5d8407..0d33d72 100644 --- a/source3/modules/wscript_build +++ b/source3/modules/wscript_build @@ -132,7 +132,8 @@ bld.SAMBA3_MODULE('vfs_shadow_copy', deps='samba-util', init_function='', internal_module=bld.SAMBA3_IS_STATIC_MODULE('vfs_shadow_copy'), - enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_shadow_copy')) + enabled=bld.SAMBA3_IS_ENABLED_MODULE('vfs_shadow_copy'), + cflags="-Wformat-length") bld.SAMBA3_MODULE('vfs_shadow_copy2', subsystem='vfs', -- 2.7.4 >From 9929b012a171a21c7b4ac9e9bac9bf29146eee05 Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 1 Nov 2016 13:28:56 +1300 Subject: [PATCH 3/4] s3/message_dgm: avoid GCC qualms over snprintf length --- source3/wscript_build | 1 + 1 file changed, 1 insertion(+) diff --git a/source3/wscript_build b/source3/wscript_build index 22e1a62..21b19f5 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -314,6 +314,7 @@ bld.SAMBA3_SUBSYSTEM('TDB_LIB', bld.SAMBA3_LIBRARY('messages_dgm', source='''lib/messages_dgm.c lib/messages_dgm_ref.c''', deps='''talloc samba-debug PTHREADPOOL msghdr genrand''', + cflags="-Wformat-length", private_library=True) bld.SAMBA3_LIBRARY('messages_util', -- 2.7.4 >From a4b7929eaa03465e42f3d9785bd5e6b34aed766a Mon Sep 17 00:00:00 2001 From: Douglas Bagnall Date: Tue, 1 Nov 2016 14:18:38 +1300 Subject: [PATCH 4/4] smbclient: fix string formatting in print command At one time, the variables lname and rname were char arrays, but now they are pointers. When they were arrays, sizeof(rname) was the length of the array, but now it gives the size of the pointer which is not what we want. In the case where the filename is -, rname was alloced as size 1, which could never fit the name it wanted to have contain ("stdin-"). Signed-off-by: Douglas Bagnall --- source4/client/client.c | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/source4/client/client.c b/source4/client/client.c index 4807123..71ec32e 100644 --- a/source4/client/client.c +++ b/source4/client/client.c @@ -1535,14 +1535,16 @@ static int cmd_print(struct smbclient_context *ctx, const char **args) lname = talloc_strdup(ctx, args[1]); - rname = talloc_strdup(ctx, lname); - p = strrchr_m(rname,'/'); - if (p) { - slprintf(rname, sizeof(rname)-1, "%s-%d", p+1, (int)getpid()); - } - - if (strequal(lname,"-")) { - slprintf(rname, sizeof(rname)-1, "stdin-%d", (int)getpid()); + if (strequal(lname, "-")) { + rname = talloc_array(ctx, char, 20); + slprintf(rname, 19, "stdin-%d", (int)getpid()); + } else { + rname = talloc_strdup(ctx, lname); + p = strrchr_m(rname, '/'); + if (p) { + slprintf(rname, strlen(rname), "%s-%d", p+1, + (int)getpid()); + } } return do_put(ctx, rname, lname, false); -- 2.7.4