[Toybox] Chromium's producing even _more_ insane ps data.

Rob Landley rob at landley.net
Mon Jun 6 16:14:16 PDT 2016


On 06/06/2016 04:51 PM, enh wrote:
> (fwiw, the Android security folks have wanted something like this in
> the past. i've always tried to suggest they don't parse the output of
> tools for security stuff, though, so they know exactly what they're
> looking at, and exactly what transformations it's undergone.)

I'm all for it, but "something like this" is too vague to implement. :)
I can do a "ps -wo PID,RAWCMD" pretty easily, but the question is what
RAWCMD's behavior should be.

Easy thing to do: I can put "quotes" around all arguments (including
argv0), not trim the initial path, and the octal escape logic used by
/proc/mounts. (The advantage of this method is echo -e "the string"
de-escapes it, but I could also do a \xHH hex variant if that's easier
for modern audiences to read). I'd have escape " too (so space, tab,
newline backslash, and quote would get escaped).

That's the EASY 90%. The remaining problem there is that UTF8 could
easily hide stuff with combining characters and such from quick visual
inspection.

I could say "hexdump the output to see weirdness", or to further make
visual inspection work I could either \escape everything >= 127 (not
showing unicode at all), or I could use a different type of escapes.

The crunch_escape() UTF8 escape logic I've already got in
lib/linestack.c can turn all the low ascii and combining characters into:

  if (wc<' ') rc = sprintf(buf, "^%c", '@'+wc);
  else if (wc<256) rc = sprintf(buf, "<%02X>", wc);
  else rc = sprintf(buf, "U+%04X", wc);

Basically the current crunch_str() but with wcwidth() of 0 escaped too.
(Of course without combining characters a lot of unicode's gonna look
kinda weird...)

Rob



More information about the Toybox mailing list