Commit 3b02df57 authored by Tycho Andersen's avatar Tycho Andersen Committed by Pavel Emelyanov

util: don't chop off last element in buffer

377763e5 is incorrect since we can't always chop off the last element in
the buffer:

Execute static/cgroup00
./cgroup00 --pidfile=cgroup00.pid --outfile=cgroup00.out --dirname=cgroup00.test
Dump 12819
(00.003514) Error (files-reg.c:624): Can't create link remap for /dev/nul. Use link-remap option.
(00.003523) Error (cr-dump.c:1257): Dump files (pid: 12819) failed with -1
(00.004042) Error (cr-dump.c:1619): Dumping FAILED.
WARNING: cgroup00 returned 1 and left running for debug needs
Test: zdtm/live/static/cgroup00, Result: FAIL
==================================== ERROR ====================================
Test: zdtm/live/static/cgroup00, Namespace:
================================= ERROR OVER =================================

Hopefully the >= will appease coverity (instead of just a ==).
Signed-off-by: 's avatarTycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: 's avatarPavel Emelyanov <xemul@parallels.com>
parent ff3f52d2
......@@ -463,11 +463,11 @@ int read_fd_link(int lfd, char *buf, size_t size)
if (ret < 0) {
pr_perror("Can't read link of fd %d", lfd);
return -1;
} else if ((size_t)ret == size) {
} else if ((size_t)ret >= size) {
pr_err("Buffer for read link of fd %d is too small\n", lfd);
return -1;
}
buf[ret - 1] = 0;
buf[ret] = 0;
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