summaryrefslogtreecommitdiff
path: root/procps
diff options
context:
space:
mode:
authorDenys Vlasenko <vda.linux@googlemail.com>2021-10-07 21:55:16 +0200
committerDenys Vlasenko <vda.linux@googlemail.com>2021-10-07 21:55:16 +0200
commiteb048a450cc7a0d92ac435a59d56f378b9f82667 (patch)
tree4bfd84e1786f02c6e525dd087bb756ea5f64e4a1 /procps
parent421c8767ba4ebf02fadc056026033e8feaf1a470 (diff)
downloadbusybox-eb048a450cc7a0d92ac435a59d56f378b9f82667.tar.gz
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>
Diffstat (limited to 'procps')
-rw-r--r--procps/ps.c32
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)
opt = comma + 1;
continue;
}
- break;
- }
- // opt points to last spec in comma separated list.
- // This one can have =HEADER part.
- new = new_out_t();
- if (equal)
- *equal = '\0';
- *new = *find_out_spec(opt);
- if (equal) {
- *equal = '=';
- new->header = equal + 1;
+ // opt points to last spec in comma separated list.
+ // This one can have =HEADER part.
+ new = new_out_t();
+ if (equal)
+ *equal = '\0';
+ *new = *find_out_spec(opt);
+ if (!equal)
+ break;
+ *equal++ = '=';
+ new->header = equal;
+ comma = strchr(equal, ',');
+ if (comma)
+ *comma = '\0';
// POSIX: the field widths shall be ... at least as wide as
// the header text (default or overridden value).
// If the header text is null, such as -o user=,
@@ -461,10 +463,12 @@ static void parse_o(char* opt)
// default header text
if (new->header[0]) {
new->width = strlen(new->header);
- print_header = 1;
}
- } else
- print_header = 1;
+ if (!comma)
+ break;
+ //*comma = ','; /* no, new->header should stay NUL-terminated */
+ opt = comma + 1;
+ }
}
static void alloc_line_buffer(void)