From: Qualys Security Advisory <qsa@qualys.com> Date: Thu, 1 Jan 1970 00:00:00 +0000 (+0000) Subject: pidof: Get the arg1 base name with get_basename(). X-Git-Tag: v3.3.15~125 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=6cadda2b4fb12958ab7c8e612d726ca47cde6798;p=procps-ng pidof: Get the arg1 base name with get_basename(). Same as program_base, cmd_arg0base, and exe_link_base. --- diff --git a/pidof.c b/pidof.c index e73c23e7..c2b2eb4c 100644 --- a/pidof.c +++ b/pidof.c @@ -136,7 +136,6 @@ static void select_procs (void) static int size = 0; char *cmd_arg0, *cmd_arg0base; char *cmd_arg1, *cmd_arg1base; - char *pos; char *program_base; char *root_link; char *exe_link; @@ -193,12 +192,10 @@ static void select_procs (void) } else if (opt_scripts_too && *(task.cmdline+1)) { - pos = cmd_arg1base = cmd_arg1 = *(task.cmdline+1); + cmd_arg1 = *(task.cmdline+1); /* get the arg1 base name */ - while (*pos != '\0') { - if (*(pos++) == '/') cmd_arg1base = pos; - } + cmd_arg1base = get_basename(cmd_arg1); /* if script, then task.cmd = argv1, otherwise task.cmd = argv0 */ if (task.cmd &&