[network-manager-openvpn/NM_0_8] properties: fix use-after-free in import code



commit 5f83facb751d870c034be870cde3797a0a143e07
Author: Dan Williams <dcbw redhat com>
Date:   Tue Apr 5 21:32:41 2011 -0500

    properties: fix use-after-free in import code
    
    Was causing random test failures in determining the "direction"
    parameter of various config file lines.

 properties/import-export.c |   11 +++++++++--
 1 files changed, 9 insertions(+), 2 deletions(-)
---
diff --git a/properties/import-export.c b/properties/import-export.c
index eb5413e..44dcb88 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -112,7 +112,7 @@ unquote (const char *line, char **leftover)
 			*p = *item;
 	}
 	if (leftover && *item)
-		*leftover = item + 1;
+		*leftover = g_strdup (item + 1);
 
 	g_free (tmp);
 	return unquoted;
@@ -133,8 +133,13 @@ handle_path_item (const char *line,
 		return FALSE;
 
 	file = unquote (line + strlen (tag), leftover);
-	if (!file)
+	if (!file) {
+		if (leftover) {
+			g_free (*leftover);
+			leftover = NULL;
+		}
 		return FALSE;
+	}
 
 	/* If file isn't an absolute file name, add the default path */
 	if (!g_path_is_absolute (file))
@@ -536,6 +541,7 @@ do_import (const char *path, char **lines, GError **error)
 			                  NM_OPENVPN_KEY_STATIC_KEY_DIRECTION,
 			                  leftover,
 			                  s_vpn);
+			g_free (leftover);
 			have_sk = TRUE;
 			continue;
 		}
@@ -546,6 +552,7 @@ do_import (const char *path, char **lines, GError **error)
 			                  NM_OPENVPN_KEY_TA_DIR,
 			                  leftover,
 			                  s_vpn);
+			g_free (leftover);
 			continue;
 		}
 



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