Closed
Bug 894452
Opened 11 years ago
Closed 7 years ago
b2g-info won't correctly parse comm which has ) in it
Categories
(Firefox OS Graveyard :: General, defect)
Tracking
(Not tracked)
RESOLVED
WONTFIX
People
(Reporter: dhylands, Unassigned)
Details
The fscanf in process.cpp won't work properly if the comm contains a ) character.
For example, I created a script which I called a)b which did:
#/system/bin/sh
sleep 300
and executed it. Then the stat line looked like:
127|root@android:/data/local/tmp # cat /proc/2204/stat
2204 (a)c) S 2154 2204 2154 34817 2210 4194304 167 0 0 0 0 1 0 0 20 0 1 0 6137685 802816 98 4294967295 32768 176196 3197381536 3197380840 1074061460 0 0 0 134337775 3221474612 0 0 17 0 0 0 0 0 0
So, my conclusion is that the only correct way to parse out the comm is start at the beginning of the string and look for '('. Then start 17 characters after that and scan backwards looking for ')'.
comm will be whatever is between ( and ). You can then do a sscanf on everything after the ) to parse the remaining fields.
I don't consider this to be a high priority, but basically, if an app were to ever contain a ) in its name, then b2g-info wouldn't grab the correct information.
Comment 1•11 years ago
|
||
> I don't consider this to be a high priority, but basically, if an app were to ever
> contain a ) in its name, then b2g-info wouldn't grab the correct information.
Such as the app named "(Preallocated app)".
Although we can definitely change that. :)
Comment 2•11 years ago
|
||
(In reply to Dave Hylands [:dhylands] from comment #0)
> So, my conclusion is that the only correct way to parse out the comm is
> start at the beginning of the string and look for '('. Then start 17
> characters after that and scan backwards looking for ')'.
Will it be easier if we read the comm from /proc/[pid]/comm ?
Reporter | ||
Comment 3•11 years ago
|
||
We need the rest of the information from the stat line, so we might as well just grab it from there.
I wrote some code in dom/system/OpenFileFinder.cpp which parses the comm out using:
char *closeParen = strrchr(stat, ')');
if (!closeParen) {
return;
}
char *openParen = strchr(stat, '(');
if (!openParen) {
return;
}
if (openParen >= closeParen) {
return;
}
nsDependentCSubstring comm(&openParen[1], closeParen - openParen - 1);
and then you can use sscanf to grab the rest of the stat stuff using closeParen as your starting place.
Comment 4•7 years ago
|
||
Firefox OS is not being worked on
Status: NEW → RESOLVED
Closed: 7 years ago
Resolution: --- → WONTFIX
You need to log in
before you can comment on or make changes to this bug.
Description
•