From e2c065aec7dcf9043a6a7d3aea149d69745be5d6 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 18 Jun 2018 10:24:06 +0200 Subject: [PATCH 1/3] samdb: Fix build error with gcc8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../source4/dsdb/samdb/ldb_modules/samldb.c: In function ‘samldb_add’: ../source4/dsdb/samdb/ldb_modules/samldb.c:424:6: error: ‘found’ may be used uninitialized in this function [-Werror=maybe-uninitialized] if (found) { ^ ../source4/dsdb/samdb/ldb_modules/samldb.c:348:11: note: ‘found’ was declared here bool ok, found; ^~~~~ BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner (cherry picked from commit 76828876faa3cd463023e323983df0be597c7361) --- source4/dsdb/samdb/ldb_modules/samldb.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source4/dsdb/samdb/ldb_modules/samldb.c b/source4/dsdb/samdb/ldb_modules/samldb.c index 11da629f4ec..734d0be26a9 100644 --- a/source4/dsdb/samdb/ldb_modules/samldb.c +++ b/source4/dsdb/samdb/ldb_modules/samldb.c @@ -345,7 +345,7 @@ static int samldb_generate_next_linkid(struct samldb_ctx *ac, static int samldb_schema_add_handle_linkid(struct samldb_ctx *ac) { int ret; - bool ok, found; + bool ok, found = false; struct ldb_message_element *el; const char *enc_str; const struct dsdb_attribute *attr; -- 2.17.1 From 16cbfc28e72d4de8e23f8cc0bb41fbd01d3b6d59 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 18 Jun 2018 10:34:27 +0200 Subject: [PATCH 2/3] s3:registry: Fix buffer truncation issues issues with gcc8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../source3/registry/reg_perfcount.c: In function ‘reg_perfcount_get_hkpd’: ../source3/registry/reg_perfcount.c:337:29: error: ‘snprintf’ output may be truncated before the last format character [-Werror=format-truncation=] snprintf(buf, buflen,"%d%s", key_part1, key_part2); BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner (cherry picked from commit 29f6842ee86b768f3677b38c5640655e312c398e) --- source3/registry/reg_perfcount.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/source3/registry/reg_perfcount.c b/source3/registry/reg_perfcount.c index a8f76ac66b2..db4451ecdeb 100644 --- a/source3/registry/reg_perfcount.c +++ b/source3/registry/reg_perfcount.c @@ -166,13 +166,12 @@ static uint32_t _reg_perfcount_multi_sz_from_tdb(TDB_CONTEXT *tdb, uint32_t buffer_size) { TDB_DATA kbuf, dbuf; - char temp[256]; + char temp[PERFCOUNT_MAX_LEN] = {0}; char *buf1 = *retbuf; uint32_t working_size = 0; DATA_BLOB name_index, name; bool ok; - memset(temp, 0, sizeof(temp)); snprintf(temp, sizeof(temp), "%d", keyval); kbuf = string_tdb_data(temp); dbuf = tdb_fetch(tdb, kbuf); @@ -709,13 +708,13 @@ static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *in TDB_CONTEXT *names) { TDB_DATA key, data; - char buf[PERFCOUNT_MAX_LEN], temp[PERFCOUNT_MAX_LEN]; + char buf[PERFCOUNT_MAX_LEN] = {0}; + char temp[32] = {0}; smb_ucs2_t *name = NULL; int pad; /* First grab the instance data from the data file */ - memset(temp, 0, PERFCOUNT_MAX_LEN); - snprintf(temp, PERFCOUNT_MAX_LEN, "i%d", instId); + snprintf(temp, sizeof(temp), "i%d", instId); _reg_perfcount_make_key(&key, buf, PERFCOUNT_MAX_LEN, obj->ObjectNameTitleIndex, temp); if (!_reg_perfcount_get_counter_data(key, &data)) { DEBUG(3, ("_reg_perfcount_get_counter_data failed\n")); @@ -739,8 +738,7 @@ static bool _reg_perfcount_get_instance_info(struct PERF_INSTANCE_DEFINITION *in SAFE_FREE(data.dptr); /* Fetch instance name */ - memset(temp, 0, PERFCOUNT_MAX_LEN); - snprintf(temp, PERFCOUNT_MAX_LEN, "i%dname", instId); + snprintf(temp, sizeof(temp), "i%dname", instId); _reg_perfcount_make_key(&key, buf, PERFCOUNT_MAX_LEN, obj->ObjectNameTitleIndex, temp); data = tdb_fetch(names, key); if(data.dptr == NULL) -- 2.17.1 From d9b22aa3fe4fd84dc2b9002e0cb62ca480eb21fb Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Mon, 18 Jun 2018 10:43:53 +0200 Subject: [PATCH 3/3] s3:smbget: Fix buffer truncation issues with gcc8 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ../source3/utils/smbget.c: In function ‘smb_download_file’: ../source3/utils/smbget.c:97:27: error: ‘b’ directive output may be truncated writing 1 byte into a region of size between 0 and 19 [-Werror=format-truncation=] snprintf(buffer, l, "%jdb", (intmax_t)s); ^ BUG: https://bugzilla.samba.org/show_bug.cgi?id=13437 Signed-off-by: Andreas Schneider Reviewed-by: Guenther Deschner (cherry picked from commit 4a3164e0beea35c1f4ce44fbe43547f7104587d1) --- source3/utils/smbget.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/utils/smbget.c b/source3/utils/smbget.c index d2d5e00a8ed..e1be42917fb 100644 --- a/source3/utils/smbget.c +++ b/source3/utils/smbget.c @@ -288,7 +288,7 @@ static void print_progress(const char *name, time_t start, time_t now, double avg = 0.0; long eta = -1; double prcnt = 0.0; - char hpos[20], htotal[20], havg[20]; + char hpos[22], htotal[22], havg[22]; char *status, *filename; int len; if (now - start) { -- 2.17.1