Bug 1817

Summary: lastlog is not recorded with the big uid
Product: Portable OpenSSH Reporter: jchadima
Component: sshdAssignee: Assigned to nobody <unassigned-bugs>
Status: CLOSED FIXED    
Severity: normal CC: djm
Priority: P2    
Version: 5.6p1   
Hardware: All   
OS: All   
Attachments:
Description Flags
Patch solving the problem
none
/home/djm/sshd-loginrec-types.diff dtucker: ok+

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