Commit a4c9efe1 authored by Adrian Reber's avatar Adrian Reber Committed by Andrei Vagin

cr-service: fix gcc-8 error

The latest patches to cr-service.c broke compilation with gcc-8:

criu/cr-service.c: In function ‘setup_opts_from_req’:
criu/cr-service.c:323:3: error: ‘strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
   strncpy(images_dir_path, opts.imgs_dir, PATH_MAX);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
criu/cr-service.c:343:3: error: ‘strncpy’ specified bound 4096 equals destination size [-Werror=stringop-truncation]
   strncpy(work_dir_path, opts.work_dir, PATH_MAX);
   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

This fixes the errors by specifying the strncpy() size as 'PATH_MAX - 1'.
Signed-off-by: 's avatarAdrian Reber <areber@redhat.com>
Signed-off-by: 's avatarAndrei Vagin <avagin@virtuozzo.com>
parent 99d52ec7
...@@ -320,7 +320,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -320,7 +320,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
* * apply_config(rpc_conf) * * apply_config(rpc_conf)
*/ */
if (opts.imgs_dir && imgs_changed_by_rpc_conf) if (opts.imgs_dir && imgs_changed_by_rpc_conf)
strncpy(images_dir_path, opts.imgs_dir, PATH_MAX); strncpy(images_dir_path, opts.imgs_dir, PATH_MAX - 1);
else else
sprintf(images_dir_path, "/proc/%d/fd/%d", ids.pid, req->images_dir_fd); sprintf(images_dir_path, "/proc/%d/fd/%d", ids.pid, req->images_dir_fd);
...@@ -340,7 +340,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req) ...@@ -340,7 +340,7 @@ static int setup_opts_from_req(int sk, CriuOpts *req)
/* chdir to work dir */ /* chdir to work dir */
if (opts.work_dir && work_changed_by_rpc_conf) if (opts.work_dir && work_changed_by_rpc_conf)
strncpy(work_dir_path, opts.work_dir, PATH_MAX); strncpy(work_dir_path, opts.work_dir, PATH_MAX - 1);
else if (req->has_work_dir_fd) else if (req->has_work_dir_fd)
sprintf(work_dir_path, "/proc/%d/fd/%d", ids.pid, req->work_dir_fd); sprintf(work_dir_path, "/proc/%d/fd/%d", ids.pid, req->work_dir_fd);
else else
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment