From: Bernhard Walle Date: Thu, 28 Feb 2013 11:42:38 +0000 (+0100) Subject: pgrep: fix -x option X-Git-Tag: 1_22_0~263 X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=47f8558eee4caa30078daaa669f37d7cc77163fd;p=oweals%2Fbusybox.git pgrep: fix -x option Because when -x is used (exact match), then we cannot compile the regular expression with REG_NOSUB. The manual page regcomp(3) states in section "Byte offsets": Unless REG_NOSUB was set for the compilation of the pattern buffer, it is possible to obtain substring match addressing information. The problem was detected on an ARM system with glibc 2.16. Signed-off-by: Bernhard Walle Signed-off-by: Denys Vlasenko --- diff --git a/procps/pgrep.c b/procps/pgrep.c index dc7ffff48..7616027b7 100644 --- a/procps/pgrep.c +++ b/procps/pgrep.c @@ -128,7 +128,7 @@ int pgrep_main(int argc UNUSED_PARAM, char **argv) bb_show_usage(); if (argv[0]) - xregcomp(&re_buffer, argv[0], REG_EXTENDED | REG_NOSUB); + xregcomp(&re_buffer, argv[0], OPT_ANCHOR ? REG_EXTENDED : (REG_EXTENDED|REG_NOSUB); matched_pid = 0; cmd_last = NULL;