Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-12-23 Thread Donald Buczek
On 12/23/22 09:49, Thorsten Glaser wrote: Donald Buczek dixit: To be fair, this daemon doesn't use /proc/pid/stat for that, but /proc/pid/comm Yes, and that’s proper. The field in /proc/pid/stat is size-limited and so not necessarily distinct. No, it is the process name itself, which is siz

Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-12-23 Thread Thorsten Glaser
Donald Buczek dixit: > To be fair, this daemon doesn't use /proc/pid/stat for that, but > /proc/pid/comm Yes, and that’s proper. The field in /proc/pid/stat is size-limited and so not necessarily distinct. > As /proc/pid/stat is also used in many places, it could as well use > that to avoid cod

Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-12-23 Thread Donald Buczek
On 12/22/22 21:28, Thorsten Glaser wrote: Donald Buczek dixit: No, Escaping would break existing programs which parse the line by searching for the ')' from the right. Huh? No! The format is "(" + string + ") " after all, and only the string part would get escaped. The only visible change w

Bug#1024811: Re: Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-12-22 Thread Thorsten Glaser
Donald Buczek dixit: >No, Escaping would break existing programs which parse the line by >searching for the ')' from the right. Huh? No! The format is "(" + string + ") " after all, and only the string part would get escaped. The only visible change would be that programs containing a whitespac

Bug#1024811: Re: Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-12-22 Thread Donald Buczek
On 12/22/22 1:53 AM, Thorsten Glaser wrote: > On Sat, 26 Nov 2022, Alexey Dobriyan wrote: > >> /proc never escaped "comm" field of /proc/*/stat. > > Yes, that’s precisely the bug. > >> To parse /proc/*/stat reliably, search for '(' from the beginning, then >> for ')' backwards. Everything in bet

Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-12-21 Thread Thorsten Glaser
On Sat, 26 Nov 2022, Alexey Dobriyan wrote: >/proc never escaped "comm" field of /proc/*/stat. Yes, that’s precisely the bug. >To parse /proc/*/stat reliably, search for '(' from the beginning, then >for ')' backwards. Everything in between parenthesis is "comm". That’s not guaranteed to stay r

Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-11-25 Thread Thorsten Glaser
Dixi quod… >The effect is that /proc/[pid]/stat cannot be parsed the way it is >documented, as it does not escape embedded whitespace characters; … nor parenthesēs: tglase@x61w:~ $ ./mk\)sh -c 'echo $$; sleep 10' & [1] 13375 tglase@x61w:~ $ 13375 tglase@x61w:~ $ cat /proc/13375/stat 13375 (mk)sh

Bug#1024811: linux: /proc/[pid]/stat unparsable

2022-11-25 Thread Thorsten Glaser
Package: src:linux Version: 5.10.149-2 Severity: normal Tags: upstream X-Debbugs-Cc: t...@mirbsd.de, adobri...@gmail.com tglase@x61w:~ $ cp /bin/mksh mk\ sh tglase@x61w:~ $ ./mk\ sh -c 'echo $$; sleep 10' & [1] 12862 tglase@x61w:~ $ 12862 cat /proc/12862/stat 12862 (mk sh) S 12649 12862 12649 3483