Skip to content
Commit cb58aa84 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov
Browse files

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 <ldufour@linux.vnet.ibm.com>
Signed-off-by: default avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: default avatarPavel Emelyanov <xemul@virtuozzo.com>
parent c44683c1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment