Add check for old being NULL in utmp_setid(); from Steven McDonald

This commit is contained in:
Todd C. Miller
2011-09-27 09:30:59 -04:00
parent 05bfd66693
commit 7304bc744e

View File

@@ -96,10 +96,12 @@ utmp_setid(sudo_utmp_t *old, sudo_utmp_t *new)
size_t idlen; size_t idlen;
/* Skip over "tty" in the id if old entry did too. */ /* Skip over "tty" in the id if old entry did too. */
if (strncmp(line, "tty", 3) == 0) { if (old != NULL) {
idlen = MIN(sizeof(old->ut_id), 3); if (strncmp(line, "tty", 3) == 0) {
if (strncmp(old->ut_id, "tty", idlen) != 0) idlen = MIN(sizeof(old->ut_id), 3);
line += 3; if (strncmp(old->ut_id, "tty", idlen) != 0)
line += 3;
}
} }
/* Store as much as will fit, skipping parts of the beginning as needed. */ /* Store as much as will fit, skipping parts of the beginning as needed. */