From: martynas Date: Thu, 9 Jan 2014 05:07:37 +0000 (+0000) Subject: Switch to string copy rather than memcpy so we stop past '\0' and X-Git-Url: http://artulab.com/gitweb/?a=commitdiff_plain;h=4e6ebd2a2c98161c2e497c0c110a9c484ce6e4d0;p=openbsd Switch to string copy rather than memcpy so we stop past '\0' and don't copy over the garbage from the source buffer (like, leaking the canary). OK millert@. --- diff --git a/usr.bin/rwho/rwho.c b/usr.bin/rwho/rwho.c index f82ab5b59f9..598236cfb32 100644 --- a/usr.bin/rwho/rwho.c +++ b/usr.bin/rwho/rwho.c @@ -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;