Commit b84babe6 authored by Andrey Vagin's avatar Andrey Vagin Committed by Cyrill Gorcunov

get_image_path: calculate size of string correctly

Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarCyrill Gorcunov <gorcunov@openvz.org>
parent 4ba93d08
...@@ -239,9 +239,11 @@ int get_image_path(char *path, int size, const char *fmt, int pid) ...@@ -239,9 +239,11 @@ int get_image_path(char *path, int size, const char *fmt, int pid)
strcpy(path, image_dir); strcpy(path, image_dir);
path[image_dir_size] = '/'; path[image_dir_size] = '/';
size -= image_dir_size + 1;
ret = snprintf(path + image_dir_size + 1, size, fmt, pid); ret = snprintf(path + image_dir_size + 1, size, fmt, pid);
if (ret == -1 || ret > size) { if (ret == -1 || ret >= size) {
pr_err("can't get image path"); pr_err("can't get image path\n");
return -1; return -1;
} }
return 0; return 0;
......
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