James Hunt has proposed merging lp:~jamesodhunt/upstart/bug-1197225 into 
lp:upstart.

Requested reviews:
  Upstart Reviewers (upstart-reviewers)
Related bugs:
  Bug #1197225 in upstart : "upstart-file-bridge assert failure: string.c:396: 
Assertion failed in nih_str_split: str != NULL"
  https://bugs.launchpad.net/upstart/+bug/1197225

For more details, see:
https://code.launchpad.net/~jamesodhunt/upstart/bug-1197225/+merge/172762

Fix for bug 1197225, which also affected 2 of the other bridges.
-- 
https://code.launchpad.net/~jamesodhunt/upstart/bug-1197225/+merge/172762
Your team Upstart Reviewers is requested to review the proposed merge of 
lp:~jamesodhunt/upstart/bug-1197225 into lp:upstart.
=== modified file 'ChangeLog'
--- ChangeLog	2013-06-28 13:21:34 +0000
+++ ChangeLog	2013-07-03 08:29:30 +0000
@@ -1,3 +1,12 @@
+2013-07-03  James Hunt  <[email protected]>
+
+	* extra/upstart-dbus-bridge.c: main(): Check nih_str_split() return.
+	* extra/upstart-event-bridge.c: main(): Check nih_str_split() return.
+	* extra/upstart-file-bridge.c: main():
+	  - Check nih_str_split() return.
+	  - Only attempt to extract PID from UPSTART_SESSION
+	    in user mode (LP: #1197225).
+
 2013-06-28  James Hunt  <[email protected]>
 
 	* NEWS: Release 1.9

=== modified file 'extra/upstart-dbus-bridge.c'
--- extra/upstart-dbus-bridge.c	2013-06-26 09:15:41 +0000
+++ extra/upstart-dbus-bridge.c	2013-07-03 08:29:30 +0000
@@ -297,7 +297,8 @@
 		if (user_mode) {
 			/* Extract PID from UPSTART_SESSION */
 			user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
-			for (int i = 0; user_session_path[i] != NULL; i++)
+
+			for (int i = 0; user_session_path && user_session_path[i]; i++)
 				path_element = user_session_path[i];
 
 			if (! path_element) {

=== modified file 'extra/upstart-event-bridge.c'
--- extra/upstart-event-bridge.c	2013-01-23 19:18:43 +0000
+++ extra/upstart-event-bridge.c	2013-07-03 08:29:30 +0000
@@ -209,7 +209,8 @@
 
 		/* Extract PID from UPSTART_SESSION */
 		user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
-		for (int i = 0; user_session_path[i] != NULL; i++)
+
+		for (int i = 0; user_session_path && user_session_path[i]; i++)
 			path_element = user_session_path[i];
 
 		if (! path_element) {

=== modified file 'extra/upstart-file-bridge.c'
--- extra/upstart-file-bridge.c	2013-03-28 16:55:36 +0000
+++ extra/upstart-file-bridge.c	2013-07-03 08:29:30 +0000
@@ -547,24 +547,28 @@
 		 * the Upstart instance (last part of the DBus path) in the filename.
 		 */
 
-		/* Extract PID from UPSTART_SESSION */
-		user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
-		for (int i = 0; user_session_path[i] != NULL; i++)
-			path_element = user_session_path[i];
-
-		if (! path_element) {
-			nih_fatal (_("Invalid value for UPSTART_SESSION"));
-			exit (1);
-		}
-
-		pidfile_path = getenv ("XDG_RUNTIME_DIR");
-		if (! pidfile_path)
-			pidfile_path = getenv ("HOME");
-
-		if (pidfile_path) {
-			NIH_MUST (nih_strcat_sprintf (&pidfile, NULL, "%s/upstart-file-bridge.%s.pid",
-					                        pidfile_path, path_element));
-			nih_main_set_pidfile (pidfile);
+		if (user) {
+
+			/* Extract PID from UPSTART_SESSION */
+			user_session_path = nih_str_split (NULL, user_session_addr, "/", TRUE);
+
+			for (int i = 0; user_session_path && user_session_path[i]; i++)
+				path_element = user_session_path[i];
+
+			if (! path_element) {
+				nih_fatal (_("Invalid value for UPSTART_SESSION"));
+				exit (1);
+			}
+
+			pidfile_path = getenv ("XDG_RUNTIME_DIR");
+			if (! pidfile_path)
+				pidfile_path = getenv ("HOME");
+
+			if (pidfile_path) {
+				NIH_MUST (nih_strcat_sprintf (&pidfile, NULL, "%s/upstart-file-bridge.%s.pid",
+							pidfile_path, path_element));
+				nih_main_set_pidfile (pidfile);
+			}
 		}
 
 		if (nih_main_daemonise () < 0) {

-- 
upstart-devel mailing list
[email protected]
Modify settings or unsubscribe at: 
https://lists.ubuntu.com/mailman/listinfo/upstart-devel

Reply via email to