mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
criu: fix gcc-8 warnings
criu/sk-packet.c:443:3: error: 'strncpy' output may be truncated
copying 14 bytes from a string of length 15
strncpy(addr_spkt.sa_data, req.ifr_name, sa_data_size);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/img-remote.c:383:3: error: 'strncpy' specified bound 4096
equals destination size
strncpy(snapshot_id, li->snapshot_id, PATHLEN);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/img-remote.c:384:3: error: 'strncpy' specified bound 4096
equals destination size
strncpy(path, li->name, PATHLEN);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/files.c:288:3: error: 'strncpy' output may be truncated copying
4095 bytes from a string of length 4096
strncpy(buf, link->name, PATH_MAX - 1);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/sk-unix.c:239:36: error: '/' directive output may be truncated
writing 1 byte into a region of size between 0 and 4095
snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
^
criu/sk-unix.c:239:3: note: 'snprintf' output 3 or more bytes
(assuming 4098) into a destination of size 4096
snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/mount.c:2563:3: error: 'strncpy' specified bound 4096 equals
destination size
strncpy(path, m->mountpoint, PATH_MAX);
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/cr-restore.c:3647:2: error: 'strncpy' specified bound 16 equals
destination size
strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Signed-off-by: Andrei Vagin <avagin@virtuozzo.com>
This commit is contained in:
parent
7f5e8649b0
commit
4130507209
7 changed files with 21 additions and 8 deletions
|
|
@ -3337,7 +3337,8 @@ static int sigreturn_restore(pid_t pid, struct task_restore_args *task_args, uns
|
|||
log_get_logstart(&task_args->logstart);
|
||||
task_args->sigchld_act = sigchld_act;
|
||||
|
||||
strncpy(task_args->comm, core->tc->comm, sizeof(task_args->comm));
|
||||
strncpy(task_args->comm, core->tc->comm, TASK_COMM_LEN - 1);
|
||||
task_args->comm[TASK_COMM_LEN - 1] = 0;
|
||||
|
||||
/*
|
||||
* Fill up per-thread data.
|
||||
|
|
|
|||
|
|
@ -284,7 +284,8 @@ static int fixup_overlayfs(struct fd_parms *p, struct fd_link *link)
|
|||
char buf[PATH_MAX];
|
||||
int n;
|
||||
|
||||
strncpy(buf, link->name, PATH_MAX - 1);
|
||||
strncpy(buf, link->name, PATH_MAX);
|
||||
buf[PATH_MAX - 1] = 0;
|
||||
n = snprintf(link->name, PATH_MAX, "%s/%s", m->mountpoint, buf + 2);
|
||||
if (n >= PATH_MAX) {
|
||||
pr_err("Not enough space to replace %s\n", buf);
|
||||
|
|
|
|||
|
|
@ -25,7 +25,7 @@ struct fd_link {
|
|||
union {
|
||||
/* Link info for generic file (path) */
|
||||
struct {
|
||||
char name[PATH_MAX + 1];
|
||||
char name[PATH_MAX];
|
||||
size_t len;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2560,7 +2560,8 @@ static int fixup_remap_mounts()
|
|||
char path[PATH_MAX];
|
||||
int len;
|
||||
|
||||
strncpy(path, m->mountpoint, PATH_MAX);
|
||||
strncpy(path, m->mountpoint, PATH_MAX - 1);
|
||||
path[PATH_MAX - 1] = 0;
|
||||
len = print_ns_root(m->nsid, 0, path, PATH_MAX);
|
||||
path[len] = '/';
|
||||
|
||||
|
|
|
|||
|
|
@ -440,7 +440,7 @@ static int open_packet_sk_spkt(PacketSockEntry *pse, int *new_fd)
|
|||
goto err;
|
||||
}
|
||||
|
||||
strncpy(addr_spkt.sa_data, req.ifr_name, sa_data_size);
|
||||
memcpy(addr_spkt.sa_data, req.ifr_name, sa_data_size);
|
||||
addr_spkt.sa_data[sa_data_size - 1] = 0;
|
||||
|
||||
if (bind(sk, &addr_spkt, sizeof(addr_spkt)) < 0) {
|
||||
|
|
|
|||
|
|
@ -238,7 +238,10 @@ static int resolve_rel_name(struct unix_sk_desc *sk, const struct fd_parms *p)
|
|||
}
|
||||
dir[ret] = 0;
|
||||
|
||||
snprintf(path, sizeof(path), ".%s/%s", dir, sk->name);
|
||||
if (snprintf(path, sizeof(path), ".%s/%s", dir, sk->name) >= sizeof(path)) {
|
||||
pr_err("The path .%s/%s is too long", dir, sk->name);
|
||||
goto err;
|
||||
}
|
||||
if (fstatat(mntns_root, path, &st, 0)) {
|
||||
if (errno == ENOENT)
|
||||
continue;
|
||||
|
|
|
|||
11
lib/c/criu.c
11
lib/c/criu.c
|
|
@ -1075,9 +1075,16 @@ static int criu_connect(criu_opts *opts, bool d)
|
|||
memset(&addr, 0, sizeof(addr));
|
||||
addr.sun_family = AF_LOCAL;
|
||||
|
||||
strncpy(addr.sun_path, opts->service_address, sizeof(addr.sun_path));
|
||||
addr_len = strlen(opts->service_address);
|
||||
if (addr_len >= sizeof(addr.sun_path)) {
|
||||
fprintf(stderr, "The service address %s is too long",
|
||||
opts->service_address);
|
||||
close(fd);
|
||||
return -1;
|
||||
}
|
||||
memcpy(addr.sun_path, opts->service_address, addr_len);
|
||||
|
||||
addr_len = strlen(opts->service_address) + sizeof(addr.sun_family);
|
||||
addr_len += sizeof(addr.sun_family);
|
||||
|
||||
ret = connect(fd, (struct sockaddr *) &addr, addr_len);
|
||||
if (ret < 0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue