Blame SOURCES/openchange-2.3-covscan.patch

afa884
diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.covscan openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c
afa884
--- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c.covscan	2018-07-19 13:53:41.281450703 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_property.c	2018-07-19 13:53:41.285450703 +0200
afa884
@@ -53,6 +53,7 @@ static void openchange_all_string_sub(ch
afa884
 	}
afa884
 }
afa884
 
afa884
+#if 0
afa884
 struct RRULE_byday {
afa884
 	uint16_t	DayOfWeek;
afa884
 	const char	*DayName;
afa884
@@ -68,6 +69,7 @@ static const struct RRULE_byday RRULE_by
afa884
 	{ 0x0006,	"SA" },
afa884
 	{ 0x0007,	NULL }
afa884
 };
afa884
+#endif
afa884
 
afa884
 static const char *get_filename(const char *filename)
afa884
 {
afa884
diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c.covscan openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c
afa884
--- openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c.covscan	2018-07-19 13:53:41.281450703 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libexchange2ical/exchange2ical_utils.c	2018-07-19 13:53:41.285450703 +0200
afa884
@@ -232,7 +232,7 @@ uint32_t get_exchange_rdfDays_from_ical(
afa884
 
afa884
 struct icaltimetype get_icaltimetype_from_tm(struct tm *tm)
afa884
 {
afa884
-	struct icaltimetype tt;
afa884
+	struct icaltimetype tt = icaltime_null_time ();
afa884
 
afa884
 	tt.year   = tm->tm_year+1900;
afa884
 	tt.month  = tm->tm_mon+1;
afa884
@@ -259,7 +259,7 @@ struct icaltimetype get_icaltimetype_fro
afa884
 
afa884
 struct icaltimetype get_icaldate_from_tm(struct tm *tm)
afa884
 {
afa884
-	struct icaltimetype tt;
afa884
+	struct icaltimetype tt = icaltime_null_time ();
afa884
 
afa884
 	tt.year   = tm->tm_year+1900;
afa884
 	tt.month  = tm->tm_mon+1;
afa884
@@ -267,6 +267,7 @@ struct icaltimetype get_icaldate_from_tm
afa884
 	tt.hour   = 0;
afa884
 	tt.minute = 0;
afa884
 	tt.second = 0;
afa884
+	tt.zone   = NULL;
afa884
 
afa884
 	tt.is_date     = 1;
afa884
 	tt.is_daylight = 0;
afa884
@@ -292,7 +293,7 @@ struct tm *get_tm_from_FILETIME(const st
afa884
 
afa884
 struct icaltimetype get_icaltime_from_FILETIME(const struct FILETIME *ft)
afa884
 {
afa884
-	struct icaltimetype	tt;
afa884
+	struct icaltimetype	tt = icaltime_null_time ();
afa884
 	NTTIME			nttime;
afa884
 	struct timeval		temp_timeval;
afa884
 	struct tm		*tm;
afa884
@@ -317,7 +318,7 @@ struct icaltimetype get_icaltime_from_FI
afa884
 
afa884
 struct icaltimetype get_icaltime_from_FILETIME_UTC(const struct FILETIME *ft)
afa884
 {
afa884
-	struct icaltimetype	tt;
afa884
+	struct icaltimetype	tt = icaltime_null_time ();
afa884
 	NTTIME			nttime;
afa884
 	struct timeval		temp_timeval;
afa884
 	struct tm		*tm;
afa884
@@ -342,7 +343,7 @@ struct icaltimetype get_icaltime_from_FI
afa884
 
afa884
 struct icaltimetype get_icaldate_from_FILETIME(const struct FILETIME *ft)
afa884
 {
afa884
-	struct icaltimetype	tt;
afa884
+	struct icaltimetype	tt = icaltime_null_time ();
afa884
 	NTTIME			nttime;
afa884
 	struct timeval		temp_timeval;
afa884
 	struct tm		*tm;
afa884
@@ -373,7 +374,7 @@ struct icaltimetype get_icaldate_from_FI
afa884
 
afa884
 struct icaltimetype get_icaldate_from_GlobalObjectId(struct GlobalObjectId *GlobalObjectId)
afa884
 {
afa884
-	struct icaltimetype	tt;
afa884
+	struct icaltimetype	tt = icaltime_null_time ();
afa884
 	tt.year   = GlobalObjectId->YH;
afa884
 	tt.year   = tt.year <<8;
afa884
 	tt.year   |= GlobalObjectId->YL;
afa884
@@ -513,7 +514,10 @@ uint32_t get_minutes_from_icaltimetype(i
afa884
 	time_t			time;
afa884
 	NTTIME			nttime;
afa884
 	struct timeval 		t;
afa884
-	
afa884
+
afa884
+	if (icaltime_is_null_time(icaltime) || !icaltime_is_valid_time(icaltime))
afa884
+		return 0;
afa884
+
afa884
 	tm.tm_year	= icaltime.year - 1900;
afa884
 	tm.tm_mon 	= icaltime.month - 1;
afa884
 	tm.tm_mday	= icaltime.day;
afa884
diff -up openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c.covscan openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c
afa884
--- openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libexchange2ical/ical2exchange_property.c	2018-07-19 13:53:41.286450703 +0200
afa884
@@ -147,7 +147,6 @@ void ical2exchange_property_CATEGORIES(s
afa884
 	struct StringArray_r *sArray;
afa884
 	char **stringArray = NULL;
afa884
 	char string[256];
afa884
-	char *value;
afa884
 	char *tok;
afa884
 	icalproperty *categoriesProp;
afa884
 	uint32_t i = 0;
afa884
@@ -160,8 +159,10 @@ void ical2exchange_property_CATEGORIES(s
afa884
 	categoriesProp = icalcomponent_get_first_property(ical2exchange->categoriesEvent, ICAL_CATEGORIES_PROPERTY);
afa884
 	sArray->cValues = 0;
afa884
 	while(categoriesProp){
afa884
-	
afa884
-		value = strdup(icalproperty_get_categories(categoriesProp));
afa884
+		const char *categories = icalproperty_get_categories(categoriesProp);
afa884
+		char *value;
afa884
+
afa884
+		value = strdup(categories ? categories : "");
afa884
 		tok = strtok(value, ",");
afa884
 		while(tok){
afa884
 			if(!stringArray){
afa884
@@ -185,6 +186,7 @@ void ical2exchange_property_CATEGORIES(s
afa884
 		}
afa884
 		categoriesProp = icalcomponent_get_next_property(ical2exchange->categoriesEvent, ICAL_CATEGORIES_PROPERTY);
afa884
 
afa884
+		free(value);
afa884
 	}
afa884
 	sArray->lppszA= (const char **) stringArray;
afa884
 	
afa884
@@ -519,6 +521,7 @@ void ical2exchange_property_RRULE_EXDATE
afa884
 		
afa884
 		ritr = icalrecur_iterator_new(irt,dtstart);
afa884
 		next=icalrecur_iterator_next(ritr);
afa884
+		last = icaltime_null_time();
afa884
 		
afa884
 		while (!icaltime_is_null_time(next)){
afa884
 			last = next;
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/examples/foldertree.cpp	2018-07-19 13:53:41.286450703 +0200
afa884
@@ -65,12 +65,12 @@ int main ()
afa884
         	}
afa884
 
afa884
         }
afa884
-        catch (libmapipp::mapi_exception e) // Catch any MAPI exceptions
afa884
+        catch (libmapipp::mapi_exception &e) // Catch any MAPI exceptions
afa884
         {
afa884
                 std::cout << "MAPI Exception in main: " <<  e.what()
afa884
 			  << std::endl;
afa884
         }
afa884
-        catch (std::runtime_error e) // Catch any other runtime exceptions
afa884
+        catch (std::runtime_error &e) // Catch any other runtime exceptions
afa884
         {
afa884
                 std::cout << "std::runtime_error exception in main: "
afa884
 			  << e.what() << std::endl;
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/examples/messages.cpp	2018-07-19 13:53:41.286450703 +0200
afa884
@@ -61,12 +61,12 @@ int main ()
afa884
 			}
afa884
         	}
afa884
         }
afa884
-        catch (libmapipp::mapi_exception e) // Catch any MAPI exceptions
afa884
+        catch (libmapipp::mapi_exception &e) // Catch any MAPI exceptions
afa884
         {
afa884
                 std::cout << "MAPI Exception in main: " <<  e.what()
afa884
 			  << std::endl;
afa884
         }
afa884
-        catch (std::runtime_error e) // Catch any other runtime exceptions
afa884
+        catch (std::runtime_error &e) // Catch any other runtime exceptions
afa884
         {
afa884
                 std::cout << "std::runtime_error exception in main: "
afa884
 			  << e.what() << std::endl;
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/FXICS.c.covscan openchange-openchange-2.3-VULCAN/libmapi/FXICS.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/FXICS.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/FXICS.c	2018-07-19 13:53:41.286450703 +0200
afa884
@@ -800,6 +800,7 @@ _PUBLIC_ enum MAPISTATUS FXGetBuffer(map
afa884
 	if ((retval = mapi_object_get_logon_id(obj_source_context, &logon_id)) != MAPI_E_SUCCESS)
afa884
 		return retval;
afa884
 
afa884
+	memset(&request, 0, sizeof(struct FastTransferSourceGetBuffer_req));
afa884
 	mem_ctx = talloc_named(session, 0, "FXGetBuffer");
afa884
 	size = 0;
afa884
 
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/idset.c.covscan openchange-openchange-2.3-VULCAN/libmapi/idset.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/idset.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/idset.c	2018-07-19 13:53:41.286450703 +0200
afa884
@@ -383,6 +383,7 @@ _PUBLIC_ struct idset *IDSET_parse(TALLO
afa884
 			total_bytes += 16;
afa884
 		}
afa884
 
afa884
+		byte_count = 0;
afa884
 		globset.length = buffer.length - 16;
afa884
 		globset.data = (uint8_t *) buffer.data + 16;
afa884
 		idset->ranges = GLOBSET_parse(idset, globset, &idset->range_count, &byte_count);
afa884
@@ -1182,7 +1183,8 @@ _PUBLIC_ void RAWIDSET_push_eid(struct r
afa884
 		}
afa884
 		else {
afa884
 			glob_idset = RAWIDSET_make(rawidset->mem_ctx, true, rawidset->single);
afa884
-			last_glob_idset->next = glob_idset;
afa884
+			if (last_glob_idset)
afa884
+				last_glob_idset->next = glob_idset;
afa884
 		}
afa884
 		glob_idset->repl.id = eid_id;
afa884
 	}
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/IMAPIProp.c	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -1122,6 +1122,7 @@ _PUBLIC_ enum MAPISTATUS QueryNamedPrope
afa884
 		return retval;
afa884
 
afa884
 	/* Initialization */
afa884
+	memset(&request, 0, sizeof(struct QueryNamedProperties_req));
afa884
 	mem_ctx = talloc_named(session, 0, "QueryNamesFromIDs");
afa884
 	size = 0;
afa884
 
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/IMAPISupport.c	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -101,6 +101,7 @@ _PUBLIC_ enum MAPISTATUS Subscribe(mapi_
afa884
 	if ((retval = mapi_object_get_logon_id(obj, &logon_id)) != MAPI_E_SUCCESS)
afa884
 		return retval;
afa884
 
afa884
+	memset(&request, 0, sizeof(struct RegisterNotification_req));
afa884
 	mem_ctx = talloc_named(session, 0, "Subscribe");
afa884
 
afa884
 	/* Fill the Subscribe operation */
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/IMessage.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IMessage.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/IMessage.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/IMessage.c	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -499,6 +499,8 @@ _PUBLIC_ enum MAPISTATUS SetRecipientTyp
afa884
 	enum MAPISTATUS		retval;
afa884
 	struct SPropValue	lpProp;
afa884
 
afa884
+	memset(&lpProp, 0, sizeof(struct SPropValue));
afa884
+
afa884
 	lpProp.ulPropTag = PR_RECIPIENT_TYPE;
afa884
 	lpProp.value.l = RecipClass;
afa884
 
afa884
@@ -1648,6 +1650,7 @@ _PUBLIC_ enum MAPISTATUS OpenEmbeddedMes
afa884
 	if ((retval = mapi_object_get_logon_id(obj_attach, &logon_id)) != MAPI_E_SUCCESS)
afa884
 		return retval;
afa884
 
afa884
+	memset(&lpProp, 0, sizeof(struct SPropValue));
afa884
 	mem_ctx = talloc_named(session, 0, "OpenEmbeddedMessage");
afa884
 
afa884
 	/* Fill the OpenEmbeddedMessage request */
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/IStoreFolder.c	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -93,6 +93,7 @@ _PUBLIC_ enum MAPISTATUS OpenMessage(map
afa884
 	if ((retval = mapi_object_get_logon_id(obj_store, &logon_id)) != MAPI_E_SUCCESS)
afa884
 		return retval;
afa884
 
afa884
+	memset(&lpProp, 0, sizeof(struct SPropValue));
afa884
 	mem_ctx = talloc_named(session, 0, "OpenMessage");
afa884
 
afa884
 	/* Fill the OpenMessage operation */
afa884
@@ -232,6 +233,7 @@ _PUBLIC_ enum MAPISTATUS ReloadCachedInf
afa884
 	if ((retval = mapi_object_get_logon_id(obj_message, &logon_id)) != MAPI_E_SUCCESS)
afa884
 		return retval;
afa884
 
afa884
+	memset(&lpProp, 0, sizeof(struct SPropValue));
afa884
 	mem_ctx = talloc_named(session, 0, "ReloadCachedInformation");
afa884
 
afa884
 	/* Fill the ReloadCachedInformation operation */
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi/IStream.c.covscan openchange-openchange-2.3-VULCAN/libmapi/IStream.c
afa884
--- openchange-openchange-2.3-VULCAN/libmapi/IStream.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi/IStream.c	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -183,6 +183,7 @@ _PUBLIC_ enum MAPISTATUS ReadStream(mapi
afa884
 	if ((retval = mapi_object_get_logon_id(obj_stream, &logon_id)) != MAPI_E_SUCCESS)
afa884
 		return retval;
afa884
 
afa884
+	memset(&request, 0, sizeof(struct ReadStream_req));
afa884
 	mem_ctx = talloc_named(session, 0, "ReadStream");
afa884
 
afa884
 	*ByteRead = 0;
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/src/folder.cpp	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -57,7 +57,7 @@ folder::message_container_type folder::f
afa884
 				message_container.push_back(message_shared_ptr(new message(m_session,
afa884
 											   m_id,
afa884
 											   row_set.aRow[i].lpProps[1].value.d)));
afa884
-			} catch(mapi_exception e) {
afa884
+			} catch(mapi_exception &e) {
afa884
 				mapi_object_release(&contents_table);
afa884
 				throw;
afa884
 			}
afa884
@@ -102,7 +102,7 @@ folder::hierarchy_container_type folder:
afa884
 			try {
afa884
 				hierarchy_container.push_back(folder_shared_ptr(new folder(*this,
afa884
 							      row_set.aRow[i].lpProps[0].value.d)));
afa884
-			} catch(mapi_exception e) {
afa884
+			} catch(mapi_exception &e) {
afa884
 				mapi_object_release(&hierarchy_table);
afa884
 				throw;
afa884
 			}
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/src/message.cpp	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -50,7 +50,7 @@ message::attachment_container_type messa
afa884
 			try {
afa884
 				attachment_container.push_back(attachment_shared_ptr(new attachment(*this, row_set.aRow[i].lpProps[0].value.l)));
afa884
 			}
afa884
-			catch(mapi_exception e) {
afa884
+			catch(mapi_exception &e) {
afa884
 				mapi_object_release(&attachment_table);
afa884
 				throw;
afa884
 			}
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/src/session.cpp	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -61,7 +61,7 @@ void session::login(const std::string& p
afa884
 	if (m_profile_name == "") { // if profile is not set, try to get default profile
afa884
 		try {
afa884
 			m_profile_name = profile_database().get_default_profile_name();
afa884
-		} catch(mapi_exception e) {
afa884
+		} catch(mapi_exception &e) {
afa884
 			uninitialize();
afa884
 			throw;
afa884
 		}
afa884
@@ -74,7 +74,7 @@ void session::login(const std::string& p
afa884
 
afa884
 	try {
afa884
 		m_message_store->open(m_session);
afa884
-	} catch (mapi_exception e) {
afa884
+	} catch (mapi_exception &e) {
afa884
 		throw;
afa884
 	}
afa884
 }
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/tests/attach_test.cpp	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -84,11 +84,11 @@ int main()
afa884
 
afa884
 		print_folder_tree(top_folder, mapi_session);
afa884
 	}
afa884
-	catch (mapi_exception e) // Catch any mapi exceptions
afa884
+	catch (mapi_exception &e) // Catch any mapi exceptions
afa884
 	{
afa884
 		cout << "MAPI Exception @ main: " <<  e.what() << endl;
afa884
 	}
afa884
-	catch (std::runtime_error e) // Catch runtime exceptions
afa884
+	catch (std::runtime_error &e) // Catch runtime exceptions
afa884
 	{
afa884
 		cout << "std::runtime_error exception @ main: " << e.what() << endl;
afa884
 	}
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/tests/exception_test.cpp	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -12,7 +12,7 @@ int main()
afa884
 	try {
afa884
 		dotest();
afa884
 	}
afa884
-	catch (libmapipp::mapi_exception e) {
afa884
+	catch (libmapipp::mapi_exception &e) {
afa884
 		std::cout << e.what() << std::endl;
afa884
 	}
afa884
 	
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/tests/profile_test.cpp	2018-07-19 13:53:41.287450703 +0200
afa884
@@ -27,15 +27,18 @@
afa884
 #define PROFILEDB_NAME_TEMPLATE "/tmp/mapidbXXXXXX"
afa884
 int main ()
afa884
 {
afa884
+	char *tmpname = NULL, *tmpname2 = NULL;
afa884
+
afa884
 	try {
afa884
 		libmapipp::profile_database db;
afa884
 
afa884
 		std::cout << "default profile name: " << db.get_default_profile_name() << std::endl;
afa884
 
afa884
 		{
afa884
-			char *tmpname = (char*) calloc(sizeof(PROFILEDB_NAME_TEMPLATE) + 1, sizeof(char));
afa884
-			strncpy(tmpname, PROFILEDB_NAME_TEMPLATE, sizeof(PROFILEDB_NAME_TEMPLATE));
afa884
-			int ret = mkstemp(tmpname);
afa884
+			int ret;
afa884
+
afa884
+			tmpname = strdup(PROFILEDB_NAME_TEMPLATE);
afa884
+			ret = mkstemp(tmpname);
afa884
 			if (ret < 0) {
afa884
 				std::cout << "failed to create temporary file: " << strerror(errno) << std::endl;
afa884
 			}
afa884
@@ -45,12 +48,15 @@ int main ()
afa884
 				std::cout << "failed to create a temporary profile store" << std::endl;
afa884
 			}
afa884
 			unlink(tmpname);
afa884
+			free(tmpname);
afa884
+			tmpname = NULL;
afa884
 		}
afa884
 		
afa884
 		{
afa884
-			char *tmpname2 = (char*) calloc(sizeof(PROFILEDB_NAME_TEMPLATE) + 1, sizeof(char));
afa884
-			strncpy(tmpname2, PROFILEDB_NAME_TEMPLATE, sizeof(PROFILEDB_NAME_TEMPLATE));
afa884
-			int ret = mkstemp(tmpname2);
afa884
+			int ret;
afa884
+
afa884
+			tmpname2 = strdup(PROFILEDB_NAME_TEMPLATE);
afa884
+			ret = mkstemp(tmpname2);
afa884
 			if (ret < 0) {
afa884
 				std::cout << "failed to create temporary file: " << strerror(errno) << std::endl;
afa884
 			}
afa884
@@ -60,19 +66,33 @@ int main ()
afa884
 				std::cout << "failed to create a temporary profile store with std::string" << std::endl;
afa884
 			}
afa884
 			unlink(tmpname2);
afa884
+			free(tmpname2);
afa884
+			tmpname2 = NULL;
afa884
 		}
afa884
 
afa884
 		std::cout << "finished profile and profile database tests" << std::endl;
afa884
 	}
afa884
-	catch (libmapipp::mapi_exception e) // Catch any mapi exceptions
afa884
+	catch (libmapipp::mapi_exception &e) // Catch any mapi exceptions
afa884
 	{
afa884
 		std::cout << "MAPI Exception @ main: " <<  e.what() << std::endl;
afa884
 	}
afa884
-	catch (std::runtime_error e) // Catch runtime exceptions
afa884
+	catch (std::runtime_error &e) // Catch runtime exceptions
afa884
 	{
afa884
 		std::cout << "std::runtime_error exception @ main: " << e.what() << std::endl;
afa884
 
afa884
 	}
afa884
 
afa884
+	if (tmpname) {
afa884
+		unlink(tmpname);
afa884
+		free(tmpname);
afa884
+		tmpname = NULL;
afa884
+	}
afa884
+
afa884
+	if (tmpname2) {
afa884
+		unlink(tmpname2);
afa884
+		free(tmpname2);
afa884
+		tmpname2 = NULL;
afa884
+	}
afa884
+
afa884
 	return 0;
afa884
 }
afa884
diff -up openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp.covscan openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp
afa884
--- openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libmapi++/tests/test.cpp	2018-07-19 13:53:41.288450703 +0200
afa884
@@ -126,11 +126,11 @@ int main ()
afa884
 
afa884
 		cout << "finished session" << endl;
afa884
 	}
afa884
-	catch (mapi_exception e) // Catch any mapi exceptions
afa884
+	catch (mapi_exception &e) // Catch any mapi exceptions
afa884
 	{
afa884
 		cout << "MAPI Exception @ main: " <<  e.what() << endl;
afa884
 	}
afa884
-	catch (std::runtime_error e) // Catch runtime exceptions
afa884
+	catch (std::runtime_error &e) // Catch runtime exceptions
afa884
 	{
afa884
 		cout << "std::runtime_error exception @ main: " << e.what() << endl;
afa884
 
afa884
diff -up openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c.covscan openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c
afa884
--- openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libocpf/ocpf_api.c	2018-07-19 13:53:41.288450703 +0200
afa884
@@ -316,6 +316,8 @@ int ocpf_propvalue(struct ocpf_context *
afa884
 	if (!ocpf || !ocpf->mem_ctx) return OCPF_ERROR;
afa884
 	if (!ctx) return OCPF_ERROR;
afa884
 
afa884
+	memset(&lpProps, 0, sizeof(struct SPropValue));
afa884
+
afa884
 	switch (scope) {
afa884
 	case kw_PROPERTY:
afa884
 		/* Sanity check: do not insert the same property twice */
afa884
diff -up openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c.covscan openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c
afa884
--- openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/libocpf/ocpf_public.c	2018-07-19 13:53:41.288450703 +0200
afa884
@@ -537,6 +537,8 @@ static bool set_external_recipients(TALL
afa884
 	uint32_t		last;
afa884
 	struct SPropValue	SPropValue;
afa884
 
afa884
+	memset(&SPropValue, 0, sizeof(struct SPropValue));
afa884
+
afa884
 	SRowSet->aRow = talloc_realloc(mem_ctx, SRowSet->aRow, struct SRow, SRowSet->cRows + 2);
afa884
 	last = SRowSet->cRows;
afa884
 	SRowSet->aRow[last].cValues = 0;
afa884
@@ -626,6 +628,8 @@ _PUBLIC_ enum MAPISTATUS ocpf_set_Recipi
afa884
 
afa884
 	MAPI_RETVAL_IF(!ctx->recipients->cRows, MAPI_E_NOT_FOUND, NULL);
afa884
 
afa884
+	memset(&SPropValue, 0, sizeof(struct SPropValue));
afa884
+
afa884
 	SPropTagArray = set_SPropTagArray(mem_ctx, 0x8,
afa884
 					  PidTagObjectType,
afa884
 					  PidTagDisplayName,
afa884
diff -up openchange-openchange-2.3-VULCAN/ndr_mapi.c.covscan openchange-openchange-2.3-VULCAN/ndr_mapi.c
afa884
--- openchange-openchange-2.3-VULCAN/ndr_mapi.c.covscan	2018-07-19 13:53:41.276450703 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/ndr_mapi.c	2018-07-19 13:53:41.288450703 +0200
afa884
@@ -1310,8 +1310,11 @@ _PUBLIC_ enum ndr_err_code ndr_pull_EcDo
afa884
 		NDR_PULL_ALLOC(ndr, r->out.pulTimeStamp);
afa884
 		*r->out.pulTimeStamp = *r->in.pulTimeStamp;
afa884
 		NDR_PULL_ALLOC(ndr, r->out.pcbAuxOut);
afa884
-		*r->out.pcbAuxOut = *r->in.pcbAuxOut;
afa884
-	}		
afa884
+		if (r->in.pcbAuxOut)
afa884
+			*r->out.pcbAuxOut = *r->in.pcbAuxOut;
afa884
+		else
afa884
+			*r->out.pcbAuxOut = 0;
afa884
+	}
afa884
 
afa884
 	if (flags & NDR_OUT) {
afa884
 		if (ndr->flags & LIBNDR_FLAG_REF_ALLOC) {
afa884
diff -up openchange-openchange-2.3-VULCAN/script/makepropslist.py.covscan openchange-openchange-2.3-VULCAN/script/makepropslist.py
afa884
--- openchange-openchange-2.3-VULCAN/script/makepropslist.py.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/script/makepropslist.py	2018-07-19 13:53:41.288450703 +0200
afa884
@@ -992,7 +992,7 @@ def check_duplicate_alternative_names():
afa884
 				if previous_alternative_names.has_key(altname):
afa884
 					print "\tIn section", entry["OXPROPS_Sect"], ", alternative name:", altname, "duplicates name in section", previous_alternative_names[altname]
afa884
 				if previous_canonical_names.has_key(altname):
afa884
-					print "\tIn section", entry["OXPROPS_Sect"], ", alternative name:", altname, "duplicates canonical name in section", previous_alternative_names[altname]
afa884
+					print "\tIn section", entry["OXPROPS_Sect"], ", alternative name:", altname, "duplicates canonical name in section", previous_canonical_names[altname]
afa884
 				previous_alternative_names[altname] = (entry["OXPROPS_Sect"])
afa884
 
afa884
 def check_duplicate_propids():
afa884
diff -up openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c.covscan openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c
afa884
--- openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c.covscan	2015-05-16 17:22:04.000000000 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/testprogs/test_asyncnotif.c	2018-07-19 13:53:41.288450703 +0200
afa884
@@ -109,12 +109,16 @@ static int callback(uint16_t Notificatio
afa884
 		break;
afa884
 	case fnevMbit|fnevObjectDeleted:
afa884
 		OC_DEBUG(0, "[+] Message deleted");
afa884
+		break;
afa884
 	case fnevMbit|fnevObjectModified:
afa884
 		OC_DEBUG(0, "[+] Message modified");
afa884
+		break;
afa884
 	case fnevMbit|fnevObjectMoved:
afa884
 		OC_DEBUG(0, "[+] Message moved");
afa884
+		break;
afa884
 	case fnevMbit|fnevObjectCopied:
afa884
 		OC_DEBUG(0, "[+] Message copied");
afa884
+		break;
afa884
 	case fnevMbit|fnevTableModified:
afa884
 		ctable = (struct ContentsTableChange *) NotificationData;
afa884
 		switch (ctable->TableEvent) {
afa884
@@ -143,6 +147,7 @@ static int callback(uint16_t Notificatio
afa884
 		break;
afa884
 	case fnevMbit|fnevSbit|fnevObjectModified:
afa884
 		OC_DEBUG(0, "[+] A property on a message in a search folder has changed");
afa884
+		break;
afa884
 	case fnevMbit|fnevSbit|fnevTableModified:
afa884
 		stable = (struct ContentsTableChange *) NotificationData;
afa884
 		switch (stable->TableEvent) {
afa884
@@ -250,6 +255,7 @@ int main(int argc, const char *argv[])
afa884
 
afa884
 	retval = MAPIInitialize(&mapi_ctx, opt_profdb);
afa884
 	if (retval != MAPI_E_SUCCESS) {
afa884
+		talloc_free(mem_ctx);
afa884
 		mapi_errstr("MAPIInitialize", retval);
afa884
 		exit (1);
afa884
 	}
afa884
@@ -261,6 +267,10 @@ int main(int argc, const char *argv[])
afa884
 		SetMAPIDebugLevel(mapi_ctx, atoi(opt_debug));
afa884
 	}
afa884
 
afa884
+	mapi_object_init(&obj_store);
afa884
+	mapi_object_init(&obj_inbox);
afa884
+	mapi_object_init(&obj_contentstable);
afa884
+
afa884
 	/* if no profile is supplied use the default one */
afa884
 	if (!opt_profname) {
afa884
 		retval = GetDefaultProfile(mapi_ctx, &opt_profname);
afa884
@@ -280,7 +290,6 @@ int main(int argc, const char *argv[])
afa884
 	}
afa884
 
afa884
 	/* Open the default message store */
afa884
-	mapi_object_init(&obj_store);
afa884
 
afa884
 	retval = OpenMsgStore(session, &obj_store);
afa884
 	if (retval != MAPI_E_SUCCESS) {
afa884
@@ -292,11 +301,9 @@ int main(int argc, const char *argv[])
afa884
 	retval = GetReceiveFolder(&obj_store, &fid, NULL);
afa884
 	MAPI_RETVAL_IF(retval, retval, mem_ctx);
afa884
 
afa884
-	mapi_object_init(&obj_inbox);
afa884
 	retval = OpenFolder(&obj_store, fid, &obj_inbox);
afa884
 	MAPI_RETVAL_IF(retval, retval, mem_ctx);
afa884
 
afa884
-	mapi_object_init(&obj_contentstable);
afa884
 	retval = GetContentsTable(&obj_inbox, &obj_contentstable, 0, &count);
afa884
 	printf("mailbox contains %i messages\n", count);
afa884
 
afa884
diff -up openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.covscan openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c
afa884
--- openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c.covscan	2018-07-19 13:53:41.276450703 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/utils/mapipropsdump.c	2018-07-19 13:53:41.289450703 +0200
afa884
@@ -79,21 +79,21 @@
afa884
  */
afa884
 
afa884
 
afa884
-static const const struct ndr_interface_table *load_exchange_emsmdb_dso(const char *plugin)
afa884
+static const struct ndr_interface_table *load_exchange_emsmdb_dso(const char *plugin, void **phandle)
afa884
 {
afa884
 	const struct ndr_interface_table	*p;
afa884
-	void					*handle;
afa884
 
afa884
-	handle = dlopen(plugin, RTLD_NOW);
afa884
-	if (handle == NULL) {
afa884
+	*phandle = dlopen(plugin, RTLD_NOW);
afa884
+	if (*phandle == NULL) {
afa884
 		printf("%s: Unable to open: %s\n", plugin, dlerror());
afa884
 		return NULL;
afa884
 	}
afa884
 
afa884
-	p = (const struct ndr_interface_table *) dlsym(handle, "ndr_table_exchange_emsmdb");
afa884
+	p = (const struct ndr_interface_table *) dlsym(*phandle, "ndr_table_exchange_emsmdb");
afa884
 	if (!p) {
afa884
 		OC_DEBUG(0, "%s: Unable to find DCE/RPC interface table for 'ndr_table_exchange_emsmdb': %s", plugin, dlerror());
afa884
-		dlclose(handle);
afa884
+		dlclose(*phandle);
afa884
+		*phandle = NULL;
afa884
 		return NULL;
afa884
 	}
afa884
 
afa884
@@ -409,6 +409,7 @@ int main(int argc, const char *argv[])
afa884
 	struct SPropTagArray			*s;
afa884
 	const char				*opt_reqfile = NULL;
afa884
 	const char				*opt_replfile = NULL;
afa884
+	void					*plhandle = NULL;
afa884
 	poptContext				pc;
afa884
 	int					opt;
afa884
 	int					index = -1;
afa884
@@ -442,7 +443,7 @@ int main(int argc, const char *argv[])
afa884
 		exit (1);
afa884
 	}
afa884
 
afa884
-	p = load_exchange_emsmdb_dso(PLUGIN);
afa884
+	p = load_exchange_emsmdb_dso(PLUGIN, &plhandle);
afa884
 	if (!p) {
afa884
 		exit (1);
afa884
 	}
afa884
@@ -454,6 +455,7 @@ int main(int argc, const char *argv[])
afa884
 	s = process_request(mem_ctx, f, opt_reqfile, &opnum, &index);
afa884
 	if (!s) {
afa884
 		talloc_free(mem_ctx);
afa884
+		dlclose(plhandle);
afa884
 		exit (1);
afa884
 	}
afa884
 
afa884
@@ -461,9 +463,12 @@ int main(int argc, const char *argv[])
afa884
 	ret = process_response(mem_ctx, f, opt_replfile, s, opnum, index);
afa884
 	if (ret == -1) {
afa884
 		talloc_free(mem_ctx);
afa884
+		dlclose(plhandle);
afa884
 		exit (1);
afa884
 	}
afa884
 
afa884
 	talloc_free(mem_ctx);
afa884
+	dlclose(plhandle);
afa884
+
afa884
 	return (0);
afa884
 }
afa884
diff -up openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.covscan openchange-openchange-2.3-VULCAN/utils/openchangeclient.c
afa884
--- openchange-openchange-2.3-VULCAN/utils/openchangeclient.c.covscan	2018-07-19 13:53:41.277450703 +0200
afa884
+++ openchange-openchange-2.3-VULCAN/utils/openchangeclient.c	2018-07-19 13:53:41.289450703 +0200
afa884
@@ -629,6 +629,8 @@ static bool set_external_recipients(TALL
afa884
 	uint32_t		last;
afa884
 	struct SPropValue	SPropValue;
afa884
 
afa884
+	memset(&SPropValue, 0, sizeof(struct SPropValue));
afa884
+
afa884
 	SRowSet->aRow = talloc_realloc(mem_ctx, SRowSet->aRow, struct SRow, SRowSet->cRows + 1);
afa884
 	last = SRowSet->cRows;
afa884
 	SRowSet->aRow[last].cValues = 0;
afa884
@@ -821,6 +823,8 @@ static enum MAPISTATUS openchangeclient_
afa884
 	mapi_object_init(&obj_outbox);
afa884
 	mapi_object_init(&obj_message);
afa884
 
afa884
+	memset(&SPropValue, 0, sizeof(struct SPropValue));
afa884
+
afa884
 	if (oclient->pf == true) {
afa884
 		retval = openchangeclient_getpfdir(mem_ctx, obj_store, &obj_outbox, oclient->folder);
afa884
 		if (retval != MAPI_E_SUCCESS) return retval;