summaryrefslogtreecommitdiff
path: root/source3/registry
diff options
context:
space:
mode:
authorAndreas Schneider <asn@samba.org>2018-06-18 10:34:27 +0200
committerAndreas Schneider <asn@cryptomilk.org>2018-06-20 22:22:07 +0200
commit29f6842ee86b768f3677b38c5640655e312c398e (patch)
tree0e8d60cfb34c65c9cfe349963b5d47eefe5a3a89 /source3/registry
parent76828876faa3cd463023e323983df0be597c7361 (diff)
downloadsamba-29f6842ee86b768f3677b38c5640655e312c398e.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>
Diffstat (limited to 'source3/registry')
-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)