hal: Branch 'master'

Danny Kukawka dkukawka at kemper.freedesktop.org
Sat Jul 29 14:03:42 PDT 2006


 hald/util.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)

New commits:
diff-tree 97fa1003bebc4cf74573aaaccd62d23cd9721dde (from 43b54e7f372d1b4b4019dc6ccdae578600b92d01)
Author: Danny Kukawka <danny.kukawka at web.de>
Date:   Sat Jul 29 23:00:44 2006 +0200

    Fixed possible crash in hal_util_get_normalized_path ()
    
    Fixed len2 by using path2 to get the length, removed unused variable
    and added a check to avoid call strncpy with sizet_t < 0 which results in
    a crash of complete hald.

diff --git a/hald/util.c b/hald/util.c
index 76bf058..a73e8e8 100644
--- a/hald/util.c
+++ b/hald/util.c
@@ -276,7 +276,6 @@ hal_util_get_parent_path (const gchar *p
 gchar *
 hal_util_get_normalized_path (const gchar *path1, const gchar *path2)
 {
-	int i;
 	int len1;
 	int len2;
 	const gchar *p1;
@@ -284,18 +283,21 @@ hal_util_get_normalized_path (const gcha
 	gchar buf[HAL_PATH_MAX];
 
 	len1 = strlen (path1);
-	len2 = strlen (path1);
+	len2 = strlen (path2);
 
 	p1 = path1 + len1;
 
-	i = 0;
 	p2 = path2;
 	while (p2 < path2 + len2 && strncmp (p2, "../", 3) == 0) {
 		p2 += 3;
 
 		while (p1 >= path1 && *(--p1)!='/')
 			;
+	}
 
+	if ((p1-path1) < 0) {
+		HAL_ERROR (("Could not normalize '%s' and '%s', return 'NULL'", path1, path2)); 
+		return NULL;
 	}
 
 	strncpy (buf, path1, (p1-path1));



More information about the hal-commit mailing list