[PATCH] handle NULL from validate_connection_type()



This goes again 0.7 branch and should fix segfaults due to invalid
connection types (although it won't fix the invalid type itself).

See https://bugzilla.redhat.com/show_bug.cgi?id=475864

regards

christoph
Index: src/nm-openvpn-service.c
===================================================================
--- src/nm-openvpn-service.c	(Revision 14)
+++ src/nm-openvpn-service.c	(Arbeitskopie)
@@ -874,7 +874,17 @@
 
 	user_name = nm_setting_vpn_get_user_name (s_vpn);
 	tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_CONNECTION_TYPE);
+	
 	connection_type = validate_connection_type (tmp);
+	
+	if (!connection_type) {
+		g_set_error (error,
+		             NM_VPN_PLUGIN_ERROR,
+		             NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+		             "%s",
+		             "Invalid connection type.");
+		return FALSE;
+	}	
 
 	/* Need a username for any password-based connection types */
 	if (   !strcmp (connection_type, NM_OPENVPN_CONTYPE_PASSWORD_TLS)
@@ -932,6 +942,15 @@
 
 	tmp = nm_setting_vpn_get_data_item (s_vpn, NM_OPENVPN_KEY_CONNECTION_TYPE);
 	connection_type = validate_connection_type (tmp);
+	
+	if (!connection_type) {
+		g_set_error (error,
+		             NM_VPN_PLUGIN_ERROR,
+		             NM_VPN_PLUGIN_ERROR_BAD_ARGUMENTS,
+		             "%s",
+		             "Invalid connection type.");
+		return FALSE;
+	}
 
 	if (!strcmp (connection_type, NM_OPENVPN_CONTYPE_PASSWORD_TLS)) {
 		/* Will require a password and maybe private key password */

Attachment: signature.asc
Description: Dies ist ein digital signierter Nachrichtenteil



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]