[lxc-devel] [PATCH 4/7] coverity: check return value of fcntl in usernsexec
Stéphane Graber
stgraber at ubuntu.com
Wed Feb 12 21:45:53 UTC 2014
Signed-off-by: Stéphane Graber <stgraber at ubuntu.com>
---
src/lxc/lxc_usernsexec.c | 7 +++++--
1 file changed, 5 insertions(+), 2 deletions(-)
diff --git a/src/lxc/lxc_usernsexec.c b/src/lxc/lxc_usernsexec.c
index b82bcf8..e40fa53 100644
--- a/src/lxc/lxc_usernsexec.c
+++ b/src/lxc/lxc_usernsexec.c
@@ -69,13 +69,16 @@ static void opentty(const char * tty) {
fd = open(tty, O_RDWR | O_NONBLOCK);
if (fd == -1) {
- printf("WARN: could not reopen tty: %s", strerror(errno));
+ printf("WARN: could not reopen tty: %s\n", strerror(errno));
return;
}
flags = fcntl(fd, F_GETFL);
flags &= ~O_NONBLOCK;
- fcntl(fd, F_SETFL, flags);
+ if (fcntl(fd, F_SETFL, flags) < 0) {
+ printf("WARN: could not set fd flags: %s\n", strerror(errno));
+ return;
+ }
for (i = 0; i < fd; i++)
close(i);
--
1.9.rc1
More information about the lxc-devel
mailing list