From: Todd C. Miller Date: Tue, 27 Sep 2011 13:30:59 +0000 (-0400) Subject: Add check for old being NULL in utmp_setid(); from Steven McDonald X-Git-Tag: SUDO_1_8_3~23^2 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7304bc744ec92152bad3d85d08378d897644ddce;p=sudo Add check for old being NULL in utmp_setid(); from Steven McDonald --- diff --git a/src/utmp.c b/src/utmp.c index befbaf6f2..e3d711bee 100644 --- a/src/utmp.c +++ b/src/utmp.c @@ -96,10 +96,12 @@ utmp_setid(sudo_utmp_t *old, sudo_utmp_t *new) size_t idlen; /* Skip over "tty" in the id if old entry did too. */ - if (strncmp(line, "tty", 3) == 0) { - idlen = MIN(sizeof(old->ut_id), 3); - if (strncmp(old->ut_id, "tty", idlen) != 0) - line += 3; + if (old != NULL) { + if (strncmp(line, "tty", 3) == 0) { + idlen = MIN(sizeof(old->ut_id), 3); + if (strncmp(old->ut_id, "tty", idlen) != 0) + line += 3; + } } /* Store as much as will fit, skipping parts of the beginning as needed. */