diff options
author | Denys Vlasenko <vda.linux@googlemail.com> | 2021-10-07 21:55:16 +0200 |
---|---|---|
committer | Denys Vlasenko <vda.linux@googlemail.com> | 2021-10-07 21:55:16 +0200 |
commit | eb048a450cc7a0d92ac435a59d56f378b9f82667 (patch) | |
tree | 4bfd84e1786f02c6e525dd087bb756ea5f64e4a1 | |
parent | 421c8767ba4ebf02fadc056026033e8feaf1a470 (diff) | |
download | busybox-w32-eb048a450cc7a0d92ac435a59d56f378b9f82667.tar.gz busybox-w32-eb048a450cc7a0d92ac435a59d56f378b9f82667.tar.bz2 busybox-w32-eb048a450cc7a0d92ac435a59d56f378b9f82667.zip |
ps: fix -o pid=PID,args interpreting entire "PID,args" as header
procps-ng 3.3.15 does not do this.
(It could, allowing commas in headers and requiring
"ps -opid=PID -oargs" form for this case, but it does not).
function old new delta
parse_o 167 190 +23
Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r-- | procps/ps.c | 32 |
1 files changed, 18 insertions, 14 deletions
diff --git a/procps/ps.c b/procps/ps.c index 711b180a0..03b9c418c 100644 --- a/procps/ps.c +++ b/procps/ps.c | |||
@@ -443,17 +443,19 @@ static void parse_o(char* opt) | |||
443 | opt = comma + 1; | 443 | opt = comma + 1; |
444 | continue; | 444 | continue; |
445 | } | 445 | } |
446 | break; | 446 | // opt points to last spec in comma separated list. |
447 | } | 447 | // This one can have =HEADER part. |
448 | // opt points to last spec in comma separated list. | 448 | new = new_out_t(); |
449 | // This one can have =HEADER part. | 449 | if (equal) |
450 | new = new_out_t(); | 450 | *equal = '\0'; |
451 | if (equal) | 451 | *new = *find_out_spec(opt); |
452 | *equal = '\0'; | 452 | if (!equal) |
453 | *new = *find_out_spec(opt); | 453 | break; |
454 | if (equal) { | 454 | *equal++ = '='; |
455 | *equal = '='; | 455 | new->header = equal; |
456 | new->header = equal + 1; | 456 | comma = strchr(equal, ','); |
457 | if (comma) | ||
458 | *comma = '\0'; | ||
457 | // POSIX: the field widths shall be ... at least as wide as | 459 | // POSIX: the field widths shall be ... at least as wide as |
458 | // the header text (default or overridden value). | 460 | // the header text (default or overridden value). |
459 | // If the header text is null, such as -o user=, | 461 | // If the header text is null, such as -o user=, |
@@ -461,10 +463,12 @@ static void parse_o(char* opt) | |||
461 | // default header text | 463 | // default header text |
462 | if (new->header[0]) { | 464 | if (new->header[0]) { |
463 | new->width = strlen(new->header); | 465 | new->width = strlen(new->header); |
464 | print_header = 1; | ||
465 | } | 466 | } |
466 | } else | 467 | if (!comma) |
467 | print_header = 1; | 468 | break; |
469 | //*comma = ','; /* no, new->header should stay NUL-terminated */ | ||
470 | opt = comma + 1; | ||
471 | } | ||
468 | } | 472 | } |
469 | 473 | ||
470 | static void alloc_line_buffer(void) | 474 | static void alloc_line_buffer(void) |