[PATCH] Fix two coverity findings

Volker Lendecke Volker.Lendecke at SerNet.DE
Wed Jul 12 09:53:59 UTC 2017


Hi!

Review appreciated!

Thanks, Volker

-- 
SerNet GmbH, Bahnhofsallee 1b, 37081 Göttingen
phone: +49-551-370000-0, fax: +49-551-370000-9
AG Göttingen, HRB 2816, GF: Dr. Johannes Loxen
http://www.sernet.de, mailto:kontakt at sernet.de
-------------- next part --------------
From 31eac34696f659b6d52f919a6ee8ad68eb250565 Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Jul 2017 13:50:09 +0200
Subject: [PATCH 1/2] spoolss: Fix CID 1414784 Uninitialized scalar variable

"struct tm" can contain more members than we explicitly initialize.

Initialize them all.

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 source3/rpc_client/init_spoolss.c | 18 +++++++++---------
 1 file changed, 9 insertions(+), 9 deletions(-)

diff --git a/source3/rpc_client/init_spoolss.c b/source3/rpc_client/init_spoolss.c
index a806fc6ce09..e5f70c0b045 100644
--- a/source3/rpc_client/init_spoolss.c
+++ b/source3/rpc_client/init_spoolss.c
@@ -48,15 +48,15 @@ bool init_systemtime(struct spoolss_Time *r,
 
 time_t spoolss_Time_to_time_t(const struct spoolss_Time *r)
 {
-	struct tm unixtime;
-
-	unixtime.tm_year	= r->year - 1900;
-	unixtime.tm_mon		= r->month - 1;
-	unixtime.tm_wday	= r->day_of_week;
-	unixtime.tm_mday	= r->day;
-	unixtime.tm_hour	= r->hour;
-	unixtime.tm_min		= r->minute;
-	unixtime.tm_sec		= r->second;
+	struct tm unixtime = {
+		.tm_year	= r->year - 1900,
+		.tm_mon		= r->month - 1,
+		.tm_wday	= r->day_of_week,
+		.tm_mday	= r->day,
+		.tm_hour	= r->hour,
+		.tm_min		= r->minute,
+		.tm_sec		= r->second,
+	};
 
 	return mktime(&unixtime);
 }
-- 
2.11.0


From 6f42da5931e2e6a64d014033f8c21330c654575b Mon Sep 17 00:00:00 2001
From: Volker Lendecke <vl at samba.org>
Date: Tue, 11 Jul 2017 16:04:01 +0200
Subject: [PATCH 2/2] libwbclient: Fix CID 1414781 Dereference null return
 value

Basically a cut&paste error from somewhere else

Signed-off-by: Volker Lendecke <vl at samba.org>
---
 nsswitch/libwbclient/wbc_sid.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/nsswitch/libwbclient/wbc_sid.c b/nsswitch/libwbclient/wbc_sid.c
index baaeb60d361..77445afc5e9 100644
--- a/nsswitch/libwbclient/wbc_sid.c
+++ b/nsswitch/libwbclient/wbc_sid.c
@@ -812,7 +812,7 @@ wbcErr wbcCtxGetSidAliases(struct wbcContext *ctx,
 
 	rids = (uint32_t *)wbcAllocateMemory(response.data.num_entries,
 					     sizeof(uint32_t), NULL);
-	BAIL_ON_PTR_ERROR(sids, wbc_status);
+	BAIL_ON_PTR_ERROR(rids, wbc_status);
 
 	s = (const char *)response.extra_data.data;
 	for (i = 0; i < response.data.num_entries; i++) {
-- 
2.11.0



More information about the samba-technical mailing list