From cd2e48751c6b2178d7e607ed3ea4f0313ab33ab9 Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Wed, 5 Jan 2011 12:48:07 -0800 Subject: [PATCH] finger - Fix seg-fault * Fix a seg-fault where finger was improperly assuming that w->tty and w->host where char arrays when in fact they were simply char pointers. Reported-by: Robin Carey --- usr.bin/finger/util.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/usr.bin/finger/util.c b/usr.bin/finger/util.c index 7128808d11..6b057d9a28 100644 --- a/usr.bin/finger/util.c +++ b/usr.bin/finger/util.c @@ -142,10 +142,8 @@ enter_lastlog(PERSON *pn) if (doit) { w = walloc(pn); w->info = LASTLOG; - bcopy(ll.ll_line, w->tty, UT_LINESIZE); - w->tty[UT_LINESIZE] = 0; - bcopy(ll.ll_host, w->host, UT_HOSTSIZE); - w->host[UT_HOSTSIZE] = 0; + asprintf(&w->tty, "%s", ll.ll_line); + asprintf(&w->host, "%s", ll.ll_host); w->loginat = ll.ll_time; } } @@ -244,9 +242,10 @@ walloc(PERSON *pn) if ((w = malloc(sizeof(WHERE))) == NULL) err(1, NULL); - if (pn->whead == NULL) + bzero(w, sizeof(WHERE)); + if (pn->whead == NULL) { pn->whead = pn->wtail = w; - else { + } else { pn->wtail->next = w; pn->wtail = w; } -- 2.41.0