From fd6bbfbe0713b07d050f0318610ebd479735c661 Mon Sep 17 00:00:00 2001 From: Christian Ruppert Date: Thu, 26 Apr 2012 10:16:56 +0200 Subject: Disable some questionable lines Caused by bug 412589 I was looking at the do_mark_service() function and quickly found that the segfault is caused by a strlen() call against a NULL pointer. I also noticed it's using "/exclusive/%s.%s" so svcname.pid, all other functions are just using the svcname.. So it seems that svcname.pid was/is never used and thus not necessary at all. In relation to the above, the if statement in the do_mark_service() function ("if (ok && svcname && strcmp(svcname, service) == 0) {") needs to be fixed/improved as svcname and service are almost always equal, see my comment in the function for further details. Signed-off-by: Christian Ruppert Reported-by: Patrick McLean X-Gentoo-Bug: 412589 X-Gentoo-Bug-URL: https://bugs.gentoo.org/412589 --- src/rc/rc-applets.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/rc/rc-applets.c b/src/rc/rc-applets.c index 865b77e2..5d026828 100644 --- a/src/rc/rc-applets.c +++ b/src/rc/rc-applets.c @@ -315,9 +315,9 @@ do_mark_service(int argc, char **argv) char *svcname = getenv("RC_SVCNAME"); char *service = NULL; char *runscript_pid; - char *mtime; + /* char *mtime; */ pid_t pid; - size_t l; + /* size_t l; */ if (argc > 1) service = argv[1]; @@ -346,6 +346,13 @@ do_mark_service(int argc, char **argv) /* If we're marking ourselves then we need to inform our parent runscript process so they do not mark us based on our exit code */ + /* + * FIXME: svcname and service are almost always equal except called from a + * shell with just argv[1] - So that doesn't seem to do what Roy initially + * expected. + * See 20120424041423.GA23657@odin.qasl.de (Tue, 24 Apr 2012 06:14:23 +0200, + * openrc@gentoo.org). + */ if (ok && svcname && strcmp(svcname, service) == 0) { runscript_pid = getenv("RC_RUNSCRIPT_PID"); if (runscript_pid && sscanf(runscript_pid, "%d", &pid) == 1) @@ -355,6 +362,7 @@ do_mark_service(int argc, char **argv) /* Remove the exclusive time test. This ensures that it's not in control as well */ + /* l = strlen(RC_SVCDIR "/exclusive") + strlen(svcname) + strlen(runscript_pid) + 4; mtime = xmalloc(l); @@ -363,6 +371,7 @@ do_mark_service(int argc, char **argv) if (exists(mtime) && unlink(mtime) != 0) eerror("%s: unlink: %s", applet, strerror(errno)); free(mtime); + */ } return ok ? EXIT_SUCCESS : EXIT_FAILURE; -- cgit v1.2.3