Switch to string copy rather than memcpy so we stop past '\0' and
authormartynas <martynas@openbsd.org>
Thu, 9 Jan 2014 05:07:37 +0000 (05:07 +0000)
committermartynas <martynas@openbsd.org>
Thu, 9 Jan 2014 05:07:37 +0000 (05:07 +0000)
don't copy over the garbage from the source buffer (like, leaking
the canary).  OK millert@.

usr.bin/rwho/rwho.c

index f82ab5b..598236c 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: rwho.c,v 1.18 2013/11/27 13:32:02 okan Exp $  */
+/*     $OpenBSD: rwho.c,v 1.19 2014/01/09 05:07:37 martynas Exp $      */
 
 /*
  * Copyright (c) 1983 The Regents of the University of California.
@@ -124,7 +124,7 @@ main(int argc, char **argv)
                        }
                        if (nusers >= NUSERS)
                                errx(1, "too many users");
-                       memcpy(mp->myhost, w->wd_hostname,
+                       strncpy(mp->myhost, w->wd_hostname,
                            sizeof(mp->myhost)-1);
                        mp->myhost[sizeof(mp->myhost)-1] = '\0';
                        mp->myidle = we->we_idle;