Blame SOURCES/openchange-2.3-covscan.patch

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