From a98826f68eb6f8de878e10ddbcc6a3a2cd4970c7 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Fri, 31 Dec 2010 16:19:25 +0100 Subject: [PATCH] Avoid (quite improbable) buffer overflow --- nwhod.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/nwhod.c b/nwhod.c index 5d0cee0..4f348e6 100644 --- a/nwhod.c +++ b/nwhod.c @@ -101,8 +101,8 @@ scan_utmp(struct nwho_pkt *p, time_t now) name[9] = 0; strcpy(h->name, name); h->login_time = htonl(now - u->ut_time); - sprintf(h->con, "%.7s", u->ut_line); - sprintf(device, "/dev/%s", u->ut_line); + snprintf(h->con, sizeof(h->con), "%s", u->ut_line); + snprintf(device, sizeof(device), "/dev/%s", u->ut_line); if (stat(device, &st) < 0) continue; h->mesg_y = !!(S_IWGRP & st.st_mode); -- 2.39.2