mirror of
https://github.com/checkpoint-restore/criu
synced 2025-08-31 06:15:24 +00:00
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: Tycho Andersen <tycho.andersen@canonical.com>
Signed-off-by: Pavel Emelyanov <xemul@parallels.com>
This commit is contained in:
committed by
Pavel Emelyanov
parent
ff3f52d244
commit
3b02df57ef
4
util.c
4
util.c
@@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user