Commit c049d845 authored by Andrey Vagin's avatar Andrey Vagin Committed by Pavel Emelyanov

files: don't check uninitialized memory in create_link_remap()

Look at this strace output:
107   linkat(45, "", 1017, "./root/git/orig/criu/test/zdtm/live/static/unlink_fstat03.test (deleted)/link_remap.4", AT_EMPTY_PATH) = -1 ENOENT (No such file or director

It's obvious, that we didn't cat the file name.

Here is an error in calculation of offset for the last symbol.
The current version of code sets this offset in strlen(),
but it's actually strlen() - 1.
Signed-off-by: 's avatarAndrey Vagin <avagin@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 546f2701
...@@ -433,7 +433,7 @@ static int create_link_remap(char *path, int len, int lfd, ...@@ -433,7 +433,7 @@ static int create_link_remap(char *path, int len, int lfd,
link_name[0] = '.'; link_name[0] = '.';
memcpy(link_name + 1, path, len); memcpy(link_name + 1, path, len);
tmp = link_name + len + 1; tmp = link_name + len;
while (*tmp != '/') { while (*tmp != '/') {
BUG_ON(tmp == link_name); BUG_ON(tmp == link_name);
tmp--; tmp--;
......
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