Bug 1817 - lastlog is not recorded with the big uid
Summary: lastlog is not recorded with the big uid
Status: CLOSED FIXED
Alias: None
Product: Portable OpenSSH
Classification: Unclassified
Component: sshd (show other bugs)
Version: 5.6p1
Hardware: All All
: P2 normal
Assignee: Assigned to nobody
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-09-13 21:07 AEST by jchadima
Modified: 2011-01-24 12:33 AEDT (History)
1 user (show)

See Also:


Attachments
Patch solving the problem (573 bytes, patch)
2010-09-13 21:09 AEST, jchadima
no flags Details | Diff
/home/djm/sshd-loginrec-types.diff (4.32 KB, patch)
2010-11-05 10:48 AEDT, Damien Miller
dtucker: ok+
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description jchadima 2010-09-13 21:07:31 AEST
Description of problem:
lastlog is not recorded with the big uid (>2147483647).


   1569 /* open the file (using filemode) and seek to the login entry */
   1570 static int
   1571 lastlog_openseek(struct logininfo *li, int *fd, int filemode)
   1572 {
            ...
   1600         if (type == LL_FILE) {
   1601                 /* find this uid's offset in the lastlog file */
   1602                 offset = (off_t) ((long)li->uid * sizeof(struct
lastlog));
   1603 
   1604                 if (lseek(*fd, offset, SEEK_SET) != offset) {
   1605                         logit("%s: %s->lseek(): %s", __func__,
   1606                             lastlog_file, strerror(errno));
   1607                         return (0);
   1608                 }

When uid is 2147483648, offset is 18446743446644326400 at line 1602.

uid       = 2147483648 (0x80000000)
(long)uid = 18446744071562067968 (0xFFFFFFFF80000000)

As a result, offset becomes so big value, lseek fails, and lastlog is not
recorded. 

  lseek(9, 18446743446644326400, SEEK_SET) = -1 EINVAL (Invalid argument)
Comment 1 jchadima 2010-09-13 21:09:31 AEST
Created attachment 1924 [details]
Patch solving the problem
Comment 2 Damien Miller 2010-11-05 10:48:27 AEDT
Created attachment 1946 [details]
/home/djm/sshd-loginrec-types.diff

use correct types for loginrec
Comment 3 Damien Miller 2010-11-05 10:53:01 AEDT
correct types patch applied
Comment 4 Damien Miller 2011-01-24 12:33:32 AEDT
Move resolved bugs to CLOSED after 5.7 release