proc_parse: allocate memory for the terminating null of the string

CID 996207 (#1 of 1): Out-of-bounds access (OVERRUN)
5. alloc_strlen: Allocating insufficient memory for the terminating null of the string.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-check: don't forget close a test socket

CID 996206 (#3 of 3): Resource leak (RESOURCE_LEAK)
8. leaked_handle: Handle variable "sk" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-dump: move core_entry_free closer to core_entry_alloc

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-dump: core_entry_free should free core

CID 996205 (#1-2 of 2): Resource leak (RESOURCE_LEAK)
14. leaked_storage: Variable "core" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-dump: fix memory leak in fill_zombies_pids

CID 996204 (#1 of 1): Resource leak (RESOURCE_LEAK)
11. leaked_storage: Variable "ch" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
cr-restore: fix error handling and memory leak in read_vma

CID 996203 (#1 of 1): Resource leak (RESOURCE_LEAK)
15. leaked_storage: Variable "vma" going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
files-reg: don't forget to close fd in case of error

CID 996201 (#1 of 1): Resource leak (RESOURCE_LEAK)
9. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

CID 996202 (#1 of 1): Resource leak (RESOURCE_LEAK)
6. leaked_handle: Handle variable "fd" going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
page-pipe: fix memory leak on error path

CID 996197 (#1 of 1): Resource leak (RESOURCE_LEAK)
8. leaked_storage: Variable ppb going out of scope leaks the storage it points to.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
namespaces: close fd on the source netns in restore_ns

It's opened in switch_ns.

CID 996194 (#3 of 5): Resource leak (RESOURCE_LEAK)
11. leaked_handle: Handle variable rst going out of scope leaks the handle.

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
sysctl: Don't forget to close fds

In case if openat/open call returned fd = 0,
don't forget to close it on routine exit,
ie just use close_safe macro.

Not a big deal since the descriptors get closed
once program finish execution but still.

#CID 996183 Resource leak

Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>