From 89b3f2758741f77cfc67c2cb2096eaa5a7f1622c Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Aug 2017 07:45:04 +0200 Subject: [PATCH 1/4] s4:samdb: Fix building Samba with -O3 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit gcc error: ‘result’ may be used uninitialized This wont happen, because ldb will return and error, but the compiler doesn't understand this. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit b5283c70e3924730b567772105ec6056831a6b53) --- source4/dsdb/samdb/ldb_modules/vlv_pagination.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/dsdb/samdb/ldb_modules/vlv_pagination.c b/source4/dsdb/samdb/ldb_modules/vlv_pagination.c index 5b744e3c181..980177cb05e 100644 --- a/source4/dsdb/samdb/ldb_modules/vlv_pagination.c +++ b/source4/dsdb/samdb/ldb_modules/vlv_pagination.c @@ -436,7 +436,7 @@ static int vlv_results(struct vlv_context *ac) ac->store->num_entries - 1); for (i = first_i; i <= last_i; i++) { - struct ldb_result *result; + struct ldb_result *result = NULL; struct GUID *guid = &ac->store->results[i]; ret = vlv_search_by_dn_guid(ac->module, ac, &result, guid, -- 2.14.0 From f7837e295bf78a840ab781b74a2dd0c456a5ba79 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Aug 2017 08:23:29 +0200 Subject: [PATCH 2/4] s3:torture: Fix spoolss test to build with -O3 Initialize variables so that we do not get a build warning that they might be used uninitilized. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme (cherry picked from commit 1c3b678e7dc7481cf2e97cdf136358d5fe53d9d3) --- source4/torture/rpc/spoolss.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/source4/torture/rpc/spoolss.c b/source4/torture/rpc/spoolss.c index 14a43b97f6d..89e9a134eff 100644 --- a/source4/torture/rpc/spoolss.c +++ b/source4/torture/rpc/spoolss.c @@ -2667,8 +2667,8 @@ static bool test_EnumForms_find_one(struct torture_context *tctx, bool print_server, const char *form_name) { - union spoolss_FormInfo *info; - uint32_t count; + union spoolss_FormInfo *info = NULL; + uint32_t count = 0; bool found = false; int i; @@ -5554,11 +5554,12 @@ static bool test_SetPrinterDataEx_values(struct torture_context *tctx, for (i=0; i < ARRAY_SIZE(values); i++) { - enum winreg_Type type; - DATA_BLOB blob_in, blob_out; + enum winreg_Type type = REG_NONE; + DATA_BLOB blob_in = data_blob_null; + DATA_BLOB blob_out = data_blob_null; uint32_t ecount; struct spoolss_PrinterEnumValues *einfo; - uint32_t needed; + uint32_t needed = 0; if (torture_setting_bool(tctx, "samba3", false)) { char *q; -- 2.14.0 From e5ea0d28f36fccb4996ef195a07f38f9875594d2 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Aug 2017 08:37:38 +0200 Subject: [PATCH 3/4] s3:utils: Fix buffer size for snprintf and format string MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit GCC 7.1 produces an error: ‘snprintf’ output between 47 and 66 bytes into a destination of size 40 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme Autobuild-User(master): Ralph Böhme Autobuild-Date(master): Wed Aug 9 13:37:47 CEST 2017 on sn-devel-144 (cherry picked from commit b86f44cbd0b1fcaf39c9edec764ecef2fd6a863b) --- source3/utils/status_profile.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/utils/status_profile.c b/source3/utils/status_profile.c index 109415d37fa..829e84cef1c 100644 --- a/source3/utils/status_profile.c +++ b/source3/utils/status_profile.c @@ -126,7 +126,7 @@ static uint64_t print_count_count_samples( if (buf[0] == '\0') { snprintf(buf, buflen, - "%s %ju/sec", + "%-40s %ju/sec", name, (uintmax_t)(step / delta_sec)); } else { printf("%-40s %s %ju/sec\n", @@ -240,7 +240,7 @@ static uint64_t print_count_samples( uint64_t delta_usec) { uint64_t count = 0; - char buf[40] = { '\0', }; + char buf[60] = { '\0', }; if (delta_usec == 0) { return 0; -- 2.14.0 From 8225aa44540e605a6eb84d2316fa201495abefc1 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Wed, 9 Aug 2017 17:01:09 +0200 Subject: [PATCH 4/4] heimdal: Fix printing a short int into a string The size of portstr is too small to print an integer and we should print a short anyway. This fixes building with GCC 7.1 BUG: https://bugzilla.samba.org/show_bug.cgi?id=12930 Signed-off-by: Andreas Schneider Reviewed-by: Ralph Boehme Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Fri Aug 11 18:08:04 CEST 2017 on sn-devel-144 (cherry picked from commit abd74c3ba5e3ee3f5320bff6ed7dff4fbcb79373) --- source4/heimdal/lib/krb5/krbhst.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source4/heimdal/lib/krb5/krbhst.c b/source4/heimdal/lib/krb5/krbhst.c index 9822bfb2f6d..dae32071b14 100644 --- a/source4/heimdal/lib/krb5/krbhst.c +++ b/source4/heimdal/lib/krb5/krbhst.c @@ -326,13 +326,13 @@ krb5_krbhst_format_string(krb5_context context, const krb5_krbhst_info *host, char *hostname, size_t hostlen) { const char *proto = ""; - char portstr[7] = ""; + char portstr[7] = {0}; if(host->proto == KRB5_KRBHST_TCP) proto = "tcp/"; else if(host->proto == KRB5_KRBHST_HTTP) proto = "http://"; if(host->port != host->def_port) - snprintf(portstr, sizeof(portstr), ":%d", host->port); + snprintf(portstr, sizeof(portstr), ":%hd", host->port); snprintf(hostname, hostlen, "%s%s%s", proto, host->hostname, portstr); return 0; } -- 2.14.0