From 92091388e92749be5af336eff21ee762efdd4a47 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 23 Aug 2016 15:05:08 +1000 Subject: [PATCH 01/14] s3-lib: Remove unused function sprintf_append BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Jeremy Allison (cherry picked from commit d123085f695745cc58f3d6882bfc7ce0893d8b84) --- source3/include/proto.h | 2 -- source3/lib/util_str.c | 59 ------------------------------------------- source3/selftest/tests.py | 1 - source3/torture/t_strappend.c | 49 ----------------------------------- source3/torture/torture.c | 1 - source3/wscript_build | 1 - 6 files changed, 113 deletions(-) delete mode 100644 source3/torture/t_strappend.c diff --git a/source3/include/proto.h b/source3/include/proto.h index 36a5499..9148492 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -660,8 +660,6 @@ int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list); void ipstr_list_free(char* ipstr_list); uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr); uint64_t conv_str_size(const char * str); -void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len, - size_t *bufsize, const char *fmt, ...); int asprintf_strupper_m(char **strp, const char *fmt, ...); char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...); char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...); diff --git a/source3/lib/util_str.c b/source3/lib/util_str.c index fc87802..48e434f 100644 --- a/source3/lib/util_str.c +++ b/source3/lib/util_str.c @@ -909,65 +909,6 @@ uint64_t conv_str_size(const char * str) return lval; } -/* Append an sprintf'ed string. Double buffer size on demand. Usable without - * error checking in between. The indication that something weird happened is - * string==NULL */ - -void sprintf_append(TALLOC_CTX *mem_ctx, char **string, ssize_t *len, - size_t *bufsize, const char *fmt, ...) -{ - va_list ap; - char *newstr; - int ret; - bool increased; - - /* len<0 is an internal marker that something failed */ - if (*len < 0) - goto error; - - if (*string == NULL) { - if (*bufsize == 0) - *bufsize = 128; - - *string = talloc_array(mem_ctx, char, *bufsize); - if (*string == NULL) - goto error; - } - - va_start(ap, fmt); - ret = vasprintf(&newstr, fmt, ap); - va_end(ap); - - if (ret < 0) - goto error; - - increased = false; - - while ((*len)+ret >= *bufsize) { - increased = true; - *bufsize *= 2; - if (*bufsize >= (1024*1024*256)) - goto error; - } - - if (increased) { - *string = talloc_realloc(mem_ctx, *string, char, - *bufsize); - if (*string == NULL) { - goto error; - } - } - - StrnCpy((*string)+(*len), newstr, ret); - (*len) += ret; - free(newstr); - return; - - error: - *len = -1; - *string = NULL; -} - /* * asprintf into a string and strupper_m it after that. */ diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 4736ebc..73879e5 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -115,7 +115,6 @@ local_tests = [ "LOCAL-MESSAGING-FDPASS2a", "LOCAL-MESSAGING-FDPASS2b", "LOCAL-hex_encode_buf", - "LOCAL-sprintf_append", "LOCAL-remove_duplicate_addrs2"] for t in local_tests: diff --git a/source3/torture/t_strappend.c b/source3/torture/t_strappend.c deleted file mode 100644 index d52371e..0000000 --- a/source3/torture/t_strappend.c +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright (C) 2005 by Volker Lendecke - * - * Test harness for sprintf_append - */ - -#include "includes.h" -#include "torture/proto.h" - -bool run_local_sprintf_append(int dummy) -{ - TALLOC_CTX *mem_ctx; - char *string = NULL; - ssize_t len = 0; - size_t bufsize = 4; - int i; - - mem_ctx = talloc_init("t_strappend"); - if (mem_ctx == NULL) { - fprintf(stderr, "talloc_init failed\n"); - return false; - } - - sprintf_append(mem_ctx, &string, &len, &bufsize, ""); - assert(strlen(string) == len); - sprintf_append(mem_ctx, &string, &len, &bufsize, ""); - assert(strlen(string) == len); - sprintf_append(mem_ctx, &string, &len, &bufsize, - "01234567890123456789012345678901234567890123456789\n"); - assert(strlen(string) == len); - - - for (i=0; i<(10000); i++) { - if (i%1000 == 0) { - printf("%d %lld\r", i, (long long int)bufsize); - fflush(stdout); - } - sprintf_append(mem_ctx, &string, &len, &bufsize, "%d\n", i); - if (strlen(string) != len) { - fprintf(stderr, "sprintf_append failed: strlen(string) %lld != len %lld\n", - (long long int)strlen(string), (long long int)len); - return false; - } - } - - talloc_destroy(mem_ctx); - - return true; -} diff --git a/source3/torture/torture.c b/source3/torture/torture.c index f9766bb..ecacd1a 100644 --- a/source3/torture/torture.c +++ b/source3/torture/torture.c @@ -10526,7 +10526,6 @@ static struct { { "LOCAL-TEVENT-SELECT", run_local_tevent_select, 0}, { "LOCAL-CONVERT-STRING", run_local_convert_string, 0}, { "LOCAL-CONV-AUTH-INFO", run_local_conv_auth_info, 0}, - { "LOCAL-sprintf_append", run_local_sprintf_append, 0}, { "LOCAL-hex_encode_buf", run_local_hex_encode_buf, 0}, { "LOCAL-IDMAP-TDB-COMMON", run_idmap_tdb_common_test, 0}, { "LOCAL-remove_duplicate_addrs2", run_local_remove_duplicate_addrs2, 0}, diff --git a/source3/wscript_build b/source3/wscript_build index edf921c..8546e8d 100755 --- a/source3/wscript_build +++ b/source3/wscript_build @@ -1288,7 +1288,6 @@ bld.SAMBA3_BINARY('smbtorture' + bld.env.suffix3, torture/test_messaging_read.c torture/test_messaging_fd_passing.c torture/test_oplock_cancel.c - torture/t_strappend.c torture/bench_pthreadpool.c torture/wbc_async.c''', deps=''' -- 2.7.4 From d01398bf7edf3afdd97bded3aed0bf1c8d5eedce Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 2 Aug 2016 18:05:14 +1000 Subject: [PATCH 02/14] talloc: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 5fb54d4d814288b796a075e01c054f607d6ce571) --- lib/talloc/talloc.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/lib/talloc/talloc.c b/lib/talloc/talloc.c index 09318e9..927b7f5 100644 --- a/lib/talloc/talloc.c +++ b/lib/talloc/talloc.c @@ -2476,8 +2476,12 @@ _PUBLIC_ char *talloc_strndup_append_buffer(char *s, const char *a, size_t n) #endif static struct talloc_chunk *_vasprintf_tc(const void *t, - const char *fmt, - va_list ap) + const char *fmt, + va_list ap) PRINTF_ATTRIBUTE(2,0); + +static struct talloc_chunk *_vasprintf_tc(const void *t, + const char *fmt, + va_list ap) { int len; char *ret; -- 2.7.4 From 595fc6190e1abb3e7838504161ce06283f772c39 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 2 Aug 2016 18:17:34 +1000 Subject: [PATCH 03/14] tdb: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit b891feaf2b1db064a725e205c861dc6d0c83aca0) --- lib/tdb/tools/tdbdump.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/lib/tdb/tools/tdbdump.c b/lib/tdb/tools/tdbdump.c index 9a0a7fe..8cf3146 100644 --- a/lib/tdb/tools/tdbdump.c +++ b/lib/tdb/tools/tdbdump.c @@ -52,6 +52,9 @@ static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA dbuf, void *stat } static void log_stderr(struct tdb_context *tdb, enum tdb_debug_level level, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); + +static void log_stderr(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) { va_list ap; -- 2.7.4 From d5ec5df9ec2aee64cdc5ca0015bef2600de19c3e Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Tue, 2 Aug 2016 18:11:17 +1000 Subject: [PATCH 04/14] lib/util: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 258cf9a170f331992c916569d3b5b52b5d731226) --- lib/util/dprintf.c | 3 +++ lib/util/talloc_report.c | 8 ++++++++ 2 files changed, 11 insertions(+) diff --git a/lib/util/dprintf.c b/lib/util/dprintf.c index 90ca36c..749fb3d 100644 --- a/lib/util/dprintf.c +++ b/lib/util/dprintf.c @@ -34,6 +34,9 @@ #include "includes.h" #include "system/locale.h" +static int d_vfprintf(FILE *f, const char *format, va_list ap) + PRINTF_ATTRIBUTE(2,0); + static int d_vfprintf(FILE *f, const char *format, va_list ap) { return vfprintf(f, format, ap); diff --git a/lib/util/talloc_report.c b/lib/util/talloc_report.c index 018d9ab..5d96ddd 100644 --- a/lib/util/talloc_report.c +++ b/lib/util/talloc_report.c @@ -27,6 +27,10 @@ static char *talloc_vasprintf_append_largebuf(char *buf, ssize_t *pstr_len, const char *fmt, va_list ap) + PRINTF_ATTRIBUTE(3,0); + +static char *talloc_vasprintf_append_largebuf(char *buf, ssize_t *pstr_len, + const char *fmt, va_list ap) { ssize_t str_len = *pstr_len; size_t buflen, needed, space; @@ -89,6 +93,10 @@ fail: static char *talloc_asprintf_append_largebuf(char *buf, ssize_t *pstr_len, const char *fmt, ...) + PRINTF_ATTRIBUTE(3,4); + +static char *talloc_asprintf_append_largebuf(char *buf, ssize_t *pstr_len, + const char *fmt, ...) { va_list ap; -- 2.7.4 From 8f71fd6ce81d38ec130e295c68b012c7d200ce05 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Wed, 3 Aug 2016 00:44:24 +1000 Subject: [PATCH 05/14] ldb: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit a47e95337e96f3e62cde41680d94268f7ce58c6f) --- lib/ldb/tools/ldbdump.c | 3 +++ lib/ldb/tools/ldbutil.h | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/ldb/tools/ldbdump.c b/lib/ldb/tools/ldbdump.c index 3197d19..33f853d 100644 --- a/lib/ldb/tools/ldbdump.c +++ b/lib/ldb/tools/ldbdump.c @@ -110,6 +110,9 @@ static int traverse_fn(TDB_CONTEXT *tdb, TDB_DATA key, TDB_DATA _dbuf, void *sta } static void log_stderr(struct tdb_context *tdb, enum tdb_debug_level level, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); + +static void log_stderr(struct tdb_context *tdb, enum tdb_debug_level level, const char *fmt, ...) { va_list ap; diff --git a/lib/ldb/tools/ldbutil.h b/lib/ldb/tools/ldbutil.h index f8d3f3a..6723863 100644 --- a/lib/ldb/tools/ldbutil.h +++ b/lib/ldb/tools/ldbutil.h @@ -43,4 +43,4 @@ int ldb_search_ctrl(struct ldb_context *ldb, TALLOC_CTX *mem_ctx, struct ldb_result **result, struct ldb_dn *base, enum ldb_scope scope, const char * const *attrs, struct ldb_control **controls, - const char *exp_fmt, ...); + const char *exp_fmt, ...) PRINTF_ATTRIBUTE(8,9); -- 2.7.4 From 908a334a52b8a61296d94087a68407746929aebe Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Sun, 7 Aug 2016 18:14:31 +1000 Subject: [PATCH 06/14] s3-lib: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit e9b8751b587c1eabc4c1a7a7d75e3c4498c6ffc4) --- source3/lib/cbuf.h | 2 +- source3/lib/util_tdb.c | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/source3/lib/cbuf.h b/source3/lib/cbuf.h index 3a1524c..2fec822 100644 --- a/source3/lib/cbuf.h +++ b/source3/lib/cbuf.h @@ -181,7 +181,7 @@ int cbuf_putdw(cbuf* b, uint32_t u); * * @return number of characters written, negative on error */ -int cbuf_printf(cbuf* b, const char* fmt, ...); +int cbuf_printf(cbuf* b, const char* fmt, ...) PRINTF_ATTRIBUTE(2,3); /** diff --git a/source3/lib/util_tdb.c b/source3/lib/util_tdb.c index 7db7111..1e533e8 100644 --- a/source3/lib/util_tdb.c +++ b/source3/lib/util_tdb.c @@ -297,6 +297,9 @@ int tdb_unpack(const uint8_t *buf, int bufsize, const char *fmt, ...) Log tdb messages via DEBUG(). ****************************************************************************/ +static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, + const char *format, ...) PRINTF_ATTRIBUTE(3,4); + static void tdb_log(TDB_CONTEXT *tdb, enum tdb_debug_level level, const char *format, ...) { va_list ap; -- 2.7.4 From e32b2b148b5607b813a7b1d636afa81f19853796 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 14:16:29 +1000 Subject: [PATCH 07/14] s3-include: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 4b4d3643555a68f585e38e37604ed4ecae9137f5) --- source3/include/proto.h | 9 ++++++--- source3/include/tldap_util.h | 7 ++++--- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/source3/include/proto.h b/source3/include/proto.h index 9148492..0aa1009 100644 --- a/source3/include/proto.h +++ b/source3/include/proto.h @@ -660,9 +660,12 @@ int ipstr_list_parse(const char *ipstr_list, struct ip_service **ip_list); void ipstr_list_free(char* ipstr_list); uint64_t STR_TO_SMB_BIG_UINT(const char *nptr, const char **entptr); uint64_t conv_str_size(const char * str); -int asprintf_strupper_m(char **strp, const char *fmt, ...); -char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...); -char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...); +int asprintf_strupper_m(char **strp, const char *fmt, ...) + PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_strupper_m(TALLOC_CTX *t, const char *fmt, ...) + PRINTF_ATTRIBUTE(2,3); +char *talloc_asprintf_strlower_m(TALLOC_CTX *t, const char *fmt, ...) + PRINTF_ATTRIBUTE(2,3); bool validate_net_name( const char *name, const char *invalid_chars, int max_len); diff --git a/source3/include/tldap_util.h b/source3/include/tldap_util.h index f9d088c..5da0c94 100644 --- a/source3/include/tldap_util.h +++ b/source3/include/tldap_util.h @@ -45,18 +45,19 @@ bool tldap_make_mod_blob(struct tldap_message *existing, TALLOC_CTX *mem_ctx, const char *attrib, DATA_BLOB newval); bool tldap_make_mod_fmt(struct tldap_message *existing, TALLOC_CTX *mem_ctx, struct tldap_mod **pmods, int *pnum_mods, - const char *attrib, const char *fmt, ...); + const char *attrib, const char *fmt, ...) + PRINTF_ATTRIBUTE(6,7); const char *tldap_errstr(TALLOC_CTX *mem_ctx, struct tldap_context *ld, TLDAPRC rc); TLDAPRC tldap_search_va(struct tldap_context *ld, const char *base, int scope, const char *attrs[], int num_attrs, int attrsonly, TALLOC_CTX *mem_ctx, struct tldap_message ***res, - const char *fmt, va_list ap); + const char *fmt, va_list ap) PRINTF_ATTRIBUTE(9,0); TLDAPRC tldap_search_fmt(struct tldap_context *ld, const char *base, int scope, const char *attrs[], int num_attrs, int attrsonly, TALLOC_CTX *mem_ctx, struct tldap_message ***res, - const char *fmt, ...); + const char *fmt, ...) PRINTF_ATTRIBUTE(9,10); bool tldap_pull_uint64(struct tldap_message *msg, const char *attr, uint64_t *presult); bool tldap_pull_uint32(struct tldap_message *msg, const char *attr, -- 2.7.4 From b635e345d01650a32a568ce5bb77f64860b1285a Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 14:17:18 +1000 Subject: [PATCH 08/14] s3-netapi: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 2d47c2b7a15ce228a201dfda63455acbff981680) --- source3/lib/netapi/netapi_private.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source3/lib/netapi/netapi_private.h b/source3/lib/netapi/netapi_private.h index 897cf3d..4d02825 100644 --- a/source3/lib/netapi/netapi_private.h +++ b/source3/lib/netapi/netapi_private.h @@ -55,7 +55,9 @@ struct libnetapi_private_ctx { NET_API_STATUS libnetapi_get_password(struct libnetapi_ctx *ctx, char **password); NET_API_STATUS libnetapi_get_username(struct libnetapi_ctx *ctx, char **username); -NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, const char *format, ...); +NET_API_STATUS libnetapi_set_error_string(struct libnetapi_ctx *ctx, + const char *format, ...) + PRINTF_ATTRIBUTE(2,3); NET_API_STATUS libnetapi_get_debuglevel(struct libnetapi_ctx *ctx, char **debuglevel); WERROR libnetapi_shutdown_cm(struct libnetapi_ctx *ctx); -- 2.7.4 From e4cf982e0ab3359e314fa77d366be4133dbf9253 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 14:18:31 +1000 Subject: [PATCH 09/14] s3-libnet: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 44baf81e8342349a9131acc5d784e65247ac32a6) --- source3/libnet/libnet_join.c | 10 ++++++++++ source3/libnet/libnet_samsync_ldif.c | 3 +++ 2 files changed, 13 insertions(+) diff --git a/source3/libnet/libnet_join.c b/source3/libnet/libnet_join.c index 96a4c59..3d66eaf 100644 --- a/source3/libnet/libnet_join.c +++ b/source3/libnet/libnet_join.c @@ -79,6 +79,11 @@ static void libnet_join_set_error_string(TALLOC_CTX *mem_ctx, struct libnet_JoinCtx *r, const char *format, ...) + PRINTF_ATTRIBUTE(3,4); + +static void libnet_join_set_error_string(TALLOC_CTX *mem_ctx, + struct libnet_JoinCtx *r, + const char *format, ...) { va_list args; @@ -97,6 +102,11 @@ static void libnet_join_set_error_string(TALLOC_CTX *mem_ctx, static void libnet_unjoin_set_error_string(TALLOC_CTX *mem_ctx, struct libnet_UnjoinCtx *r, const char *format, ...) + PRINTF_ATTRIBUTE(3,4); + +static void libnet_unjoin_set_error_string(TALLOC_CTX *mem_ctx, + struct libnet_UnjoinCtx *r, + const char *format, ...) { va_list args; diff --git a/source3/libnet/libnet_samsync_ldif.c b/source3/libnet/libnet_samsync_ldif.c index 198373e..dafeade 100644 --- a/source3/libnet/libnet_samsync_ldif.c +++ b/source3/libnet/libnet_samsync_ldif.c @@ -511,6 +511,9 @@ static NTSTATUS map_populate_groups(TALLOC_CTX *mem_ctx, */ static int fprintf_attr(FILE *add_fd, const char *attr_name, + const char *fmt, ...) PRINTF_ATTRIBUTE(3,4); + +static int fprintf_attr(FILE *add_fd, const char *attr_name, const char *fmt, ...) { va_list ap; -- 2.7.4 From be523935809f8887b3f771092342b222fbfa8125 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 14:21:14 +1000 Subject: [PATCH 10/14] regedit: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 5855b039ddedd39a81eaf419d771b32e02668cd3) --- source3/utils/regedit.c | 2 +- source3/utils/regedit_dialog.c | 6 ++++++ source3/utils/regedit_dialog.h | 18 ++++++++++++------ 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/source3/utils/regedit.c b/source3/utils/regedit.c index 9db63b9..83b09b4 100644 --- a/source3/utils/regedit.c +++ b/source3/utils/regedit.c @@ -157,7 +157,7 @@ static void add_reg_key(struct regedit *regedit, struct tree_node *node, if (subkey) { msg = "Enter name of new subkey"; } - dialog_input(regedit, &name, "New Key", msg); + dialog_input(regedit, &name, "New Key", "%s", msg); if (name) { WERROR rv; struct registry_key *new_key; diff --git a/source3/utils/regedit_dialog.c b/source3/utils/regedit_dialog.c index 07fb190..21ec96c 100644 --- a/source3/utils/regedit_dialog.c +++ b/source3/utils/regedit_dialog.c @@ -1762,6 +1762,12 @@ static int dialog_input_internal(TALLOC_CTX *ctx, void *output, enum input_type type, const char *title, const char *msg, va_list ap) + PRINTF_ATTRIBUTE(5,0); + +static int dialog_input_internal(TALLOC_CTX *ctx, void *output, + enum input_type type, + const char *title, + const char *msg, va_list ap) { WERROR err; struct input_req req; diff --git a/source3/utils/regedit_dialog.h b/source3/utils/regedit_dialog.h index 5c7c84a..b8bc3bf 100644 --- a/source3/utils/regedit_dialog.h +++ b/source3/utils/regedit_dialog.h @@ -147,9 +147,12 @@ void dialog_modal_loop(struct dialog *dia, WERROR *err, enum dialog_action *action); struct dialog_section *dialog_section_label_new_va(TALLOC_CTX *ctx, - const char *msg, va_list ap); + const char *msg, + va_list ap) + PRINTF_ATTRIBUTE(2,0); struct dialog_section *dialog_section_label_new(TALLOC_CTX *ctx, - const char *msg, ...); + const char *msg, ...) + PRINTF_ATTRIBUTE(2,3); struct dialog_section *dialog_section_hsep_new(TALLOC_CTX *ctx, int sep); @@ -208,14 +211,17 @@ enum dialog_type { }; int dialog_notice(TALLOC_CTX *ctx, enum dialog_type type, - const char *title, const char *msg, ...); + const char *title, const char *msg, ...) + PRINTF_ATTRIBUTE(4,5); int dialog_input(TALLOC_CTX *ctx, const char **output, const char *title, - const char *msg, ...); + const char *msg, ...) PRINTF_ATTRIBUTE(4,5); int dialog_input_long(TALLOC_CTX *ctx, long *output, - const char *title, const char *msg, ...); + const char *title, const char *msg, ...) + PRINTF_ATTRIBUTE(4,5); int dialog_input_ulong(TALLOC_CTX *ctx, unsigned long *output, - const char *title, const char *msg, ...); + const char *title, const char *msg, ...) + PRINTF_ATTRIBUTE(4,5); struct registry_key; struct value_item; -- 2.7.4 From a620dd585d912c77e484ad732d7f0739d8c6d9c3 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 14:22:30 +1000 Subject: [PATCH 11/14] wibindd: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit 908c068979dc69ae4664a9fa31e2f91ed115b84a) --- source3/winbindd/idmap_tdb2.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c index 1b75936..fdcd44e 100644 --- a/source3/winbindd/idmap_tdb2.c +++ b/source3/winbindd/idmap_tdb2.c @@ -256,6 +256,10 @@ done: SID:xxxx ERR:xxxx */ +static NTSTATUS idmap_tdb2_script(struct idmap_tdb2_context *ctx, + struct id_map *map, const char *fmt, ...) + PRINTF_ATTRIBUTE(3,4); + static NTSTATUS idmap_tdb2_script(struct idmap_tdb2_context *ctx, struct id_map *map, const char *fmt, ...) { -- 2.7.4 From 520d1b0eb05f53da95c84ce105f7395e555fbcde Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 17:40:51 +1000 Subject: [PATCH 12/14] passdb: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit c1a791e17c6e94c7d33351c420f238b06461a044) --- source3/passdb/pdb_samba_dsdb.c | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/source3/passdb/pdb_samba_dsdb.c b/source3/passdb/pdb_samba_dsdb.c index 19c6705..97806c4 100644 --- a/source3/passdb/pdb_samba_dsdb.c +++ b/source3/passdb/pdb_samba_dsdb.c @@ -660,7 +660,13 @@ static NTSTATUS pdb_samba_dsdb_getsamupriv(struct pdb_samba_dsdb_state *state, static NTSTATUS pdb_samba_dsdb_getsampwfilter(struct pdb_methods *m, struct pdb_samba_dsdb_state *state, struct samu *sam_acct, - const char *exp_fmt, ...) _PRINTF_ATTRIBUTE(4, 5) + const char *exp_fmt, ...) + PRINTF_ATTRIBUTE(4,5); + +static NTSTATUS pdb_samba_dsdb_getsampwfilter(struct pdb_methods *m, + struct pdb_samba_dsdb_state *state, + struct samu *sam_acct, + const char *exp_fmt, ...) { struct ldb_message *priv; NTSTATUS status; @@ -885,8 +891,13 @@ static NTSTATUS pdb_samba_dsdb_update_login_attempts(struct pdb_methods *m, return NT_STATUS_NOT_IMPLEMENTED; } +static NTSTATUS pdb_samba_dsdb_getgrfilter(struct pdb_methods *m, + GROUP_MAP *map, + const char *exp_fmt, ...) + PRINTF_ATTRIBUTE(3,4); + static NTSTATUS pdb_samba_dsdb_getgrfilter(struct pdb_methods *m, GROUP_MAP *map, - const char *exp_fmt, ...) _PRINTF_ATTRIBUTE(4, 5) + const char *exp_fmt, ...) { struct pdb_samba_dsdb_state *state = talloc_get_type_abort( m->private_data, struct pdb_samba_dsdb_state); @@ -1014,7 +1025,7 @@ static NTSTATUS pdb_samba_dsdb_getgrsid(struct pdb_methods *m, GROUP_MAP *map, return NT_STATUS_NO_MEMORY; } - status = pdb_samba_dsdb_getgrfilter(m, map, filter); + status = pdb_samba_dsdb_getgrfilter(m, map, "%s", filter); TALLOC_FREE(filter); return status; } @@ -1058,7 +1069,7 @@ static NTSTATUS pdb_samba_dsdb_getgrnam(struct pdb_methods *m, GROUP_MAP *map, return NT_STATUS_NO_MEMORY; } - status = pdb_samba_dsdb_getgrfilter(m, map, filter); + status = pdb_samba_dsdb_getgrfilter(m, map, "%s", filter); TALLOC_FREE(filter); return status; } @@ -1898,9 +1909,15 @@ static void pdb_samba_dsdb_search_end(struct pdb_search *search) } static bool pdb_samba_dsdb_search_filter(struct pdb_methods *m, + struct pdb_search *search, + struct pdb_samba_dsdb_search_state **pstate, + const char *exp_fmt, ...) + PRINTF_ATTRIBUTE(4, 5); + +static bool pdb_samba_dsdb_search_filter(struct pdb_methods *m, struct pdb_search *search, struct pdb_samba_dsdb_search_state **pstate, - const char *exp_fmt, ...) _PRINTF_ATTRIBUTE(4, 5) + const char *exp_fmt, ...) { struct pdb_samba_dsdb_state *state = talloc_get_type_abort( m->private_data, struct pdb_samba_dsdb_state); -- 2.7.4 From ed3f29ff89254c8c6ddfe0df0c1e4f3607d4f376 Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 8 Aug 2016 17:59:08 +1000 Subject: [PATCH 13/14] torture: Fix format-nonliteral warning BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Andreas Schneider Reviewed-by: Jeremy Allison (cherry picked from commit b077969a72a8010b7fac37102eb1d0c1a2111fc4) --- source4/torture/dns/dlz_bind9.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source4/torture/dns/dlz_bind9.c b/source4/torture/dns/dlz_bind9.c index de07f67..d7f4c99 100644 --- a/source4/torture/dns/dlz_bind9.c +++ b/source4/torture/dns/dlz_bind9.c @@ -33,6 +33,9 @@ struct torture_context *tctx_static; static void dlz_bind9_log_wrapper(int level, const char *fmt, ...) + PRINTF_ATTRIBUTE(2,3); + +static void dlz_bind9_log_wrapper(int level, const char *fmt, ...) { va_list ap; char *msg; -- 2.7.4 From 27525590d6bf6d253e8bef6d06753d2713c57dfb Mon Sep 17 00:00:00 2001 From: Amitay Isaacs Date: Mon, 22 Aug 2016 02:53:00 +1000 Subject: [PATCH 14/14] lib/util: Fix format strings and argument data types BUG: https://bugzilla.samba.org/show_bug.cgi?id=12168 Signed-off-by: Amitay Isaacs Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Wed Aug 24 05:32:15 CEST 2016 on sn-devel-144 (cherry picked from commit 04126d54d5430c5e2fdbbfea58d76b253b81a407) --- lib/util/talloc_report.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/util/talloc_report.c b/lib/util/talloc_report.c index 5d96ddd..63213a0 100644 --- a/lib/util/talloc_report.c +++ b/lib/util/talloc_report.c @@ -146,18 +146,18 @@ static void talloc_report_str_helper(const void *ptr, int depth, int max_depth, state->s = talloc_asprintf_append_largebuf( state->s, &state->str_len, "%*s%-30s contains %6lu bytes in %3lu blocks " - "(ref %d): %*s\n", depth*4, "", name, + "(ref %zu): %*s\n", depth*4, "", name, (unsigned long)talloc_total_size(ptr), (unsigned long)talloc_total_blocks(ptr), talloc_reference_count(ptr), - MIN(50, talloc_get_size(ptr)), + (int)MIN(50, talloc_get_size(ptr)), (const char *)ptr); return; } state->s = talloc_asprintf_append_largebuf( state->s, &state->str_len, - "%*s%-30s contains %6lu bytes in %3lu blocks (ref %d) %p\n", + "%*s%-30s contains %6lu bytes in %3lu blocks (ref %zu) %p\n", depth*4, "", name, (unsigned long)talloc_total_size(ptr), (unsigned long)talloc_total_blocks(ptr), -- 2.7.4