summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguenther <guenther>2015-12-26 20:51:35 +0000
committerguenther <guenther>2015-12-26 20:51:35 +0000
commit16fdf36d5b3e25ca96aefd8eca78a680169126bd (patch)
tree6c8bbe860b99f993e71fbae331655eefb1ba3240
parent0c8eafcf385ffdefe4d756181fdffb1ef3d08bbe (diff)
downloadfinger-master.tar
finger-master.tar.gz
Use pread/pwrite instead separate lseek+read/write for lastlog.HEADOPENBSD_6_2_BASEmaster
Cast to off_t before multiplication to avoid truncation on ILP32 ok kettenis@ mmcc@
-rw-r--r--util.c13
1 files changed, 6 insertions, 7 deletions
diff --git a/util.c b/util.c
index 976d219..14d6814 100644
--- a/util.c
+++ b/util.c
@@ -196,13 +196,12 @@ enter_lastlog(PERSON *pn)
opened = 1;
}
if (fd == -1 ||
- lseek(fd, (off_t)(pn->uid * sizeof(ll)), SEEK_SET) !=
- (long)(pn->uid * sizeof(ll)) ||
- read(fd, (char *)&ll, sizeof(ll)) != sizeof(ll)) {
- /* as if never logged in */
- ll.ll_line[0] = ll.ll_host[0] = '\0';
- ll.ll_time = 0;
- }
+ pread(fd, &ll, sizeof(ll), (off_t)pn->uid * sizeof(ll)) !=
+ sizeof(ll)) {
+ /* as if never logged in */
+ ll.ll_line[0] = ll.ll_host[0] = '\0';
+ ll.ll_time = 0;
+ }
if ((w = pn->whead) == NULL)
doit = 1;
else if (ll.ll_time != 0) {