summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-06-18 10:34:27 +0200
committerKarolin Seeger <kseeger@samba.org>2018-06-25 21:47:19 +0200
commit5f2859e958e110952b73b785975420a350497cc8 (patch)
tree715ec21b97ec54ef1f27c4c485da118144fd4701
parentbe00b892e9183e1980b8445a071003fc56f439e5 (diff)
downloadsamba-5f2859e958e110952b73b785975420a350497cc8.tar.gz
s3:registry: Fix buffer truncation issues issues with gcc8
../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 <asn@samba.org> Reviewed-by: Guenther Deschner <gd@samba.org> (cherry picked from commit 29f6842ee86b768f3677b38c5640655e312c398e)
-rw-r--r--source3/registry/reg_perfcount.c12
1 files 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)