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



commit 8a9f5617b3434ad16cdc05b594db1382648f83c6
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 56a2890..8802877 100644
--- a/properties/import-export.c
+++ b/properties/import-export.c
@@ -113,7 +113,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;
@@ -134,8 +134,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))
@@ -562,6 +567,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;
 		}
@@ -572,6 +578,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]