2
0
mirror of https://github.com/checkpoint-restore/criu synced 2025-08-30 22:05:36 +00:00

get_image_path: calculate size of string correctly

Signed-off-by: Andrey Vagin <avagin@openvz.org>
Signed-off-by: Cyrill Gorcunov <gorcunov@openvz.org>
This commit is contained in:
Andrey Vagin
2011-12-16 15:32:00 +04:00
committed by Cyrill Gorcunov
parent 4ba93d0806
commit b84babe630

View File

@@ -239,9 +239,11 @@ int get_image_path(char *path, int size, const char *fmt, int pid)
strcpy(path, image_dir);
path[image_dir_size] = '/';
size -= image_dir_size + 1;
ret = snprintf(path + image_dir_size + 1, size, fmt, pid);
if (ret == -1 || ret > size) {
pr_err("can't get image path");
if (ret == -1 || ret >= size) {
pr_err("can't get image path\n");
return -1;
}
return 0;