From 7304bc744ec92152bad3d85d08378d897644ddce Mon Sep 17 00:00:00 2001
From: "Todd C. Miller" <Todd.Miller@courtesan.com>
Date: Tue, 27 Sep 2011 09:30:59 -0400
Subject: [PATCH] Add check for old being NULL in utmp_setid(); from Steven
 McDonald

---
 src/utmp.c | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

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. */
-- 
2.40.0