[08/28] utils: Cleanup open_fd_of_vpid()

Submitted by Kirill Tkhai on June 5, 2017, 5:24 p.m.

Details

Message ID 149668348029.25229.14789151182047266122.stgit@localhost.localdomain
State New
Series "Support sockets leaked to child user_ns task"
Headers show

Commit Message

Kirill Tkhai June 5, 2017, 5:24 p.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 93337760b..3cd55180f 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 real [%s]\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;