Commit 377763e5 authored by Kir Kolyshkin's avatar Kir Kolyshkin Committed by Pavel Emelyanov

read_fd_link(): don't overrun buf

This is a classical off-by-one error. If sizeof(buf) is 512,
the last element is buf[511] but not buf[512].

Reported by Coverity, CID 114624, 114622 etc.
Signed-off-by: 's avatarKir Kolyshkin <kir@openvz.org>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent 0570dd81
...@@ -467,7 +467,7 @@ int read_fd_link(int lfd, char *buf, size_t size) ...@@ -467,7 +467,7 @@ int read_fd_link(int lfd, char *buf, size_t size)
pr_err("Buffer for read link of fd %d is too small\n", lfd); pr_err("Buffer for read link of fd %d is too small\n", lfd);
return -1; return -1;
} }
buf[ret] = 0; buf[ret - 1] = 0;
return ret; return ret;
} }
......
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