[patch] Correctly handle the case that PATH is not set

Sjoerd Simons sjoerd at luon.net
Wed Feb 1 15:25:11 PST 2006


Hi,
  
  Hald doesn't handle the case that PATH is not set (getenv returns NULL).
  Fixed in attached patch

  Sjoerd
-- 
Why don't you fix your little problem... and light this candle?
		-- Alan Shepherd, the first man into space, Gemini program
-------------- next part --------------
Index: hald/hald.c
===================================================================
RCS file: /cvs/hal/hal/hald/hald.c,v
retrieving revision 1.47
diff -u -r1.47 hald.c
--- hald/hald.c	21 Jan 2006 16:54:04 -0000	1.47
+++ hald/hald.c	1 Feb 2006 22:53:10 -0000
@@ -382,13 +382,18 @@
 	 * run-hald.sh and friends)
 	 */
 	path = getenv ("PATH");
-	g_strlcpy (newpath, path, sizeof (newpath));
 	if (path != NULL) {
+		g_strlcpy (newpath, path, sizeof (newpath));
 		g_strlcat (newpath, ":", sizeof (newpath));
-		g_strlcat (newpath, PACKAGE_LIBEXEC_DIR, sizeof (newpath));
-		g_strlcat (newpath, ":", sizeof (newpath));
-		g_strlcat (newpath, PACKAGE_SCRIPT_DIR, sizeof (newpath));
-	}
+	} else {
+		/* No PATH was set */
+		newpath[0] = '\0';
+	} 
+
+	g_strlcat (newpath, PACKAGE_LIBEXEC_DIR, sizeof (newpath));
+	g_strlcat (newpath, ":", sizeof (newpath));
+	g_strlcat (newpath, PACKAGE_SCRIPT_DIR, sizeof (newpath));
+
 	setenv ("PATH", newpath, TRUE);
 
 	while (1) {


More information about the hal mailing list