]> mj.ucw.cz Git - nwho.git/commitdiff
Avoid (quite improbable) buffer overflow
authorMartin Mares <mj@ucw.cz>
Fri, 31 Dec 2010 15:19:25 +0000 (16:19 +0100)
committerMartin Mares <mj@ucw.cz>
Fri, 31 Dec 2010 15:19:25 +0000 (16:19 +0100)
nwhod.c

diff --git a/nwhod.c b/nwhod.c
index 5d0cee02fae186192658bf61d73da082bef5f040..4f348e60d6886364613d79b5431f2d8de3ca0e99 100644 (file)
--- 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);