• Kir Kolyshkin's avatar
    prepare_pstree: fixup reading kernel pid_max · cb58aa84
    Kir Kolyshkin authored
    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: 's avatarKir Kolyshkin <kir@openvz.org>
    Signed-off-by: 's avatarPavel Emelyanov <xemul@virtuozzo.com>
    cb58aa84
Name
Last commit
Last update
Documentation Loading commit data...
contrib Loading commit data...
coredump Loading commit data...
crit Loading commit data...
criu Loading commit data...
images Loading commit data...
lib Loading commit data...
scripts Loading commit data...
test Loading commit data...
.gitignore Loading commit data...
.mailmap Loading commit data...
.travis.yml Loading commit data...
COPYING Loading commit data...
CREDITS Loading commit data...
INSTALL.md Loading commit data...
Makefile Loading commit data...
Makefile.install Loading commit data...
Makefile.versions Loading commit data...
README.md Loading commit data...