[PATCH] Some smaller fixes we probably also want to backport
Andreas Schneider
asn at samba.org
Mon Nov 12 09:33:12 UTC 2018
Hi,
attached is a patch which fixes some minor issues found by cppcheck.
Review and comments appreciated. Push if OK.
Thanks,
Andreas
--
Andreas Schneider asn at samba.org
Samba Team www.samba.org
GPG-ID: 8DFF53E18F2ABC8D8F3C92237EE0FC4DCC014E3D
-------------- next part --------------
>From 35940c2e464900982fa4bbeb48232cdba7282e25 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 12 Nov 2018 10:09:23 +0100
Subject: [PATCH 1/5] s3:rpcclient: Initialize domain_name
This could be passed uninitialized to dcerpc_netr_DsRGetDCName()
Found by cppcheck.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680
Signed-off-by: Andreas Schneider <asn at samba.org>
---
source3/rpcclient/cmd_netlogon.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/source3/rpcclient/cmd_netlogon.c b/source3/rpcclient/cmd_netlogon.c
index 8d62ef7e095..631740562c6 100644
--- a/source3/rpcclient/cmd_netlogon.c
+++ b/source3/rpcclient/cmd_netlogon.c
@@ -216,7 +216,7 @@ static WERROR cmd_netlogon_dsr_getdcname(struct rpc_pipe_client *cli,
WERROR werr = WERR_OK;
uint32_t flags = DS_RETURN_DNS_NAME;
const char *server_name = cli->desthost;
- const char *domain_name;
+ const char *domain_name = NULL;
struct GUID domain_guid = GUID_zero();
struct GUID site_guid = GUID_zero();
struct netr_DsRGetDCNameInfo *info = NULL;
--
2.19.1
>From e034a5ea9509284560c34e634927d38040d647ac Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 12 Nov 2018 10:13:51 +0100
Subject: [PATCH 2/5] librpc:ndr: Initialize inblob
Found by cppcheck.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680
Signed-off-by: Andreas Schneider <asn at samba.org>
---
librpc/ndr/ndr_backupkey.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/librpc/ndr/ndr_backupkey.c b/librpc/ndr/ndr_backupkey.c
index 827bc694230..adb6e393287 100644
--- a/librpc/ndr/ndr_backupkey.c
+++ b/librpc/ndr/ndr_backupkey.c
@@ -58,7 +58,9 @@ _PUBLIC_ void ndr_print_bkrp_BackupKey(struct ndr_print *ndr, const char *name,
ndr->flags |= LIBNDR_PRINT_SET_VALUES;
}
if (flags & NDR_IN) {
- union bkrp_data_in_blob inblob;
+ union bkrp_data_in_blob inblob = {
+ .empty._empty_ = '\0',
+ };
DATA_BLOB blob;
uint32_t level;
enum ndr_err_code ndr_err;
--
2.19.1
>From b087013d3cacb796bb40556ce58601f4a8b029c9 Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 12 Nov 2018 10:16:06 +0100
Subject: [PATCH 3/5] libgpo: Make sure status is intialized
Found by cppcheck.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680
Signed-off-by: Andreas Schneider <asn at samba.org>
---
libgpo/gpo_ldap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libgpo/gpo_ldap.c b/libgpo/gpo_ldap.c
index fec00053b49..f087203f28a 100644
--- a/libgpo/gpo_ldap.c
+++ b/libgpo/gpo_ldap.c
@@ -474,7 +474,7 @@ ADS_STATUS ads_get_gpo(ADS_STRUCT *ads,
const char *guid_name,
struct GROUP_POLICY_OBJECT *gpo)
{
- ADS_STATUS status;
+ ADS_STATUS status = ADS_ERROR(LDAP_NO_SUCH_OBJECT);
LDAPMessage *res = NULL;
char *dn;
const char *filter;
--
2.19.1
>From cabba1312ac262f6904b00fdc4f69b2a597fa3cb Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 12 Nov 2018 10:17:37 +0100
Subject: [PATCH 4/5] lib:util Always initialize start and space
Found by cppcheck.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680
Signed-off-by: Andreas Schneider <asn at samba.org>
---
lib/util/talloc_report.c | 7 ++-----
1 file changed, 2 insertions(+), 5 deletions(-)
diff --git a/lib/util/talloc_report.c b/lib/util/talloc_report.c
index 63213a014b6..bed0fd91e43 100644
--- a/lib/util/talloc_report.c
+++ b/lib/util/talloc_report.c
@@ -33,8 +33,8 @@ 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;
- char *start, *tmpbuf;
+ size_t buflen, needed, space = 0;
+ char *start = NULL, *tmpbuf = NULL;
va_list ap2;
int printlen;
@@ -52,9 +52,6 @@ static char *talloc_vasprintf_append_largebuf(char *buf, ssize_t *pstr_len,
if (buflen > str_len) {
start = buf + str_len;
space = buflen - str_len;
- } else {
- start = NULL;
- space = 0;
}
va_copy(ap2, ap);
--
2.19.1
>From 9524e46894316517497e02fa501ea55e452279aa Mon Sep 17 00:00:00 2001
From: Andreas Schneider <asn at samba.org>
Date: Mon, 12 Nov 2018 10:21:15 +0100
Subject: [PATCH 5/5] ctdb: Fix an out of bound array access
Found by cppcheck.
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13680
Signed-off-by: Andreas Schneider <asn at samba.org>
---
ctdb/common/logging.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/ctdb/common/logging.c b/ctdb/common/logging.c
index aaa93216ef5..7ed500aeb0b 100644
--- a/ctdb/common/logging.c
+++ b/ctdb/common/logging.c
@@ -85,7 +85,7 @@ const char *debug_level_to_string(int log_level)
{
int i;
- for (i=0; ARRAY_SIZE(log_string_map); i++) {
+ for (i=0; i < ARRAY_SIZE(log_string_map); i++) {
if (log_string_map[i].log_level == log_level) {
return log_string_map[i].log_string;
}
--
2.19.1
More information about the samba-technical
mailing list