From: Martin Mares Date: Fri, 31 Dec 2010 15:19:25 +0000 (+0100) Subject: Avoid (quite improbable) buffer overflow X-Git-Tag: v1.13~17 X-Git-Url: http://mj.ucw.cz/gitweb/?a=commitdiff_plain;h=a98826f68eb6f8de878e10ddbcc6a3a2cd4970c7;p=nwho.git Avoid (quite improbable) buffer overflow --- 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);