[v2,03/30] utils: Cleanup open_fd_of_vpid()

Submitted by Kirill Tkhai on June 7, 2017, 11:24 a.m.

Details

Message ID 149683464128.4663.16474973402760034817.stgit@localhost.localdomain
State Accepted
Series "Support sockets leaked to child user_ns task"
Commit 67d7029cd2f9b3d505cee87e4bd507c7425e77d1
Headers show

Commit Message

Kirill Tkhai June 7, 2017, 11:24 a.m.
Move +1 up to snprintf().

Signed-off-by: Kirill Tkhai <ktkhai@virtuozzo.com>
---
 criu/util.c |    8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

Patch hide | download patch | download mbox

diff --git a/criu/util.c b/criu/util.c
index c151c1b30..5646b223f 100644
--- a/criu/util.c
+++ b/criu/util.c
@@ -1236,14 +1236,14 @@  int open_fd_of_vpid(pid_t pid, int fd, int flags)
 	int ret;
 
 	item = pstree_pid_by_virt(pid)->item;
-	ret = sprintf(path, "%d/fd/%d", item->pid->real, fd);
+	ret = sprintf(path, "%d/fd/%d", item->pid->real, fd) + 1;
 	pr_info("Opening /proc/%s on the criu side\n", path);
 	if (flags == O_RDONLY)
-		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret + 1, -1);
+		ret = userns_call(fn_open_proc_r, UNS_FDOUT, path, ret, -1);
 	else if (flags == O_WRONLY)
-		ret = userns_call(fn_open_proc_w, UNS_FDOUT, path, ret + 1, -1);
+		ret = userns_call(fn_open_proc_w, UNS_FDOUT, path, ret, -1);
 	else if (flags == O_RDWR)
-		ret = userns_call(fn_open_proc_rw, UNS_FDOUT, path, ret + 1, -1);
+		ret = userns_call(fn_open_proc_rw, UNS_FDOUT, path, ret, -1);
 	else
 		BUG();
 	return ret;