mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 22:35:33 +00:00
Use strlcpy
It's better to 1. Use strlcpy() instead of strncpy() as otherwise we might end up with a not NULL-terminated string, which opens a portal to hell. There are a few places reported by Coverity for this, such as: - in criu_connect(), Coverity CID 51591; - in proc_pid_parse(), Coverity CID 51590; - in move_veth_to_bridge(), Coverity CID 51593; - etc. 2. Use strlcpy() instead of strcpy() to avoid buffer overruns. Some of these are also reported by Coverity, for example the one in dump_filemap(), Coverity CID 51630. Signed-off-by: Kir Kolyshkin <kir@openvz.org> Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
bf607a6ea8
commit
e5654e586c
@@ -13,6 +13,7 @@
|
||||
#include <alloca.h>
|
||||
|
||||
#include "criu.h"
|
||||
#include "string.h"
|
||||
#include "rpc.pb-c.h"
|
||||
#include "cr-service-const.h"
|
||||
|
||||
@@ -881,7 +882,7 @@ static int criu_connect(criu_opts *opts)
|
||||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_LOCAL;
|
||||
|
||||
strncpy(addr.sun_path, opts->service_address, sizeof(addr.sun_path));
|
||||
strlcpy(addr.sun_path, opts->service_address, sizeof(addr.sun_path));
|
||||
|
||||
addr_len = strlen(addr.sun_path) + sizeof(addr.sun_family);
|
||||
|
||||
|
Reference in New Issue
Block a user