summaryrefslogtreecommitdiffstats
path: root/login-utils/login.c
diff options
context:
space:
mode:
authorKarel Zak2013-03-27 14:13:00 +0100
committerKarel Zak2013-03-27 14:13:00 +0100
commit7488d4c06804ba258569f6f36aa7518f917fe291 (patch)
treecf87709363aa82c2c183f41895422dafeb6257de /login-utils/login.c
parentlibfdisk: check returns [coverity scan] (diff)
downloadkernel-qcow2-util-linux-7488d4c06804ba258569f6f36aa7518f917fe291.tar.gz
kernel-qcow2-util-linux-7488d4c06804ba258569f6f36aa7518f917fe291.tar.xz
kernel-qcow2-util-linux-7488d4c06804ba258569f6f36aa7518f917fe291.zip
login: check returns [coverity scan]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'login-utils/login.c')
-rw-r--r--login-utils/login.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/login-utils/login.c b/login-utils/login.c
index 425053406..0d2c16509 100644
--- a/login-utils/login.c
+++ b/login-utils/login.c
@@ -506,10 +506,8 @@ static void log_lastlog(struct login_context *cxt)
if (fd < 0)
return;
- if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1) {
- close(fd);
- return;
- }
+ if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
+ goto done;
/*
* Print last log message
@@ -527,7 +525,8 @@ static void log_lastlog(struct login_context *cxt)
printf(_("on %.*s\n"),
(int)sizeof(ll.ll_line), ll.ll_line);
}
- lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET);
+ if (lseek(fd, (off_t) cxt->pwd->pw_uid * sizeof(ll), SEEK_SET) == -1)
+ goto done;
}
memset((char *)&ll, 0, sizeof(ll));
@@ -542,7 +541,7 @@ static void log_lastlog(struct login_context *cxt)
if (write_all(fd, (char *)&ll, sizeof(ll)))
warn(_("write lastlog failed"));
-
+done:
close(fd);
}