Commit cb58aa8
prepare_pstree: fixup reading kernel pid_max
Two fixes (reported by coverity) and a minor nitpick:
1. Fix checking error from open_proc().
2. Fix buffer overflow. MAX_ULONG can be 20 characters long, so
ret = read() can return 20 and buf[ret] = 0 will overrun the buf.
Make a buf one character longer (an extra byte for \0) and pass
sizeof(buf) - 1 to read to fix it.
3. Call close() right after read().
This is a fixup to commit e68bded.
Reported by Coverity, CID 168505, 168504.
Cc: Laurent Dufour <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Pavel Emelyanov <[email protected]>1 parent c44683c commit cb58aa8
1 file changed
+4
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
890 | | - | |
| 890 | + | |
891 | 891 | | |
892 | 892 | | |
893 | | - | |
894 | | - | |
| 893 | + | |
| 894 | + | |
| 895 | + | |
895 | 896 | | |
896 | 897 | | |
897 | 898 | | |
898 | 899 | | |
899 | 900 | | |
900 | | - | |
901 | 901 | | |
902 | 902 | | |
903 | 903 | | |
| |||
0 commit comments