diff options
author | 2015-12-01 17:05:25 +0000 | |
---|---|---|
committer | 2015-12-01 17:05:25 +0000 | |
commit | 2282c45e4851e04974b8eb804bb5490e29a61b45 (patch) | |
tree | 9251d2c075e1af65aef14881d3580b153cbb857e /lib/libc/sys/stack_protector.c | |
parent | Iterating on &ifnet should only be done with the KERNEL_LOCK held. (diff) | |
download | wireguard-openbsd-2282c45e4851e04974b8eb804bb5490e29a61b45.tar.xz wireguard-openbsd-2282c45e4851e04974b8eb804bb5490e29a61b45.zip |
use strlcat instead of strlcpy with modified arguments. ok deraadt@
Diffstat (limited to 'lib/libc/sys/stack_protector.c')
-rw-r--r-- | lib/libc/sys/stack_protector.c | 11 |
1 files changed, 5 insertions, 6 deletions
diff --git a/lib/libc/sys/stack_protector.c b/lib/libc/sys/stack_protector.c index b7d9a364ae2..abaf7b56034 100644 --- a/lib/libc/sys/stack_protector.c +++ b/lib/libc/sys/stack_protector.c @@ -1,4 +1,4 @@ -/* $OpenBSD: stack_protector.c,v 1.20 2015/11/25 00:16:40 deraadt Exp $ */ +/* $OpenBSD: stack_protector.c,v 1.21 2015/12/01 17:05:25 canacar Exp $ */ /* * Copyright (c) 2002 Hiroaki Etoh, Federico G. Schwindt, and Miodrag Vallat. @@ -53,7 +53,6 @@ __stack_smash_handler(const char func[], int damaged) struct sigaction sa; sigset_t mask; char buf[1024]; - size_t len; /* Immediately block all signal handlers from running code */ sigfillset(&mask); @@ -61,11 +60,11 @@ __stack_smash_handler(const char func[], int damaged) sigprocmask(SIG_SETMASK, &mask, NULL); /* <10> is LOG_CRIT */ - len = strlcpy(buf, "<10>", sizeof buf); - strlcpy(buf + len, __progname, sizeof buf - len); + strlcpy(buf, "<10>", sizeof buf); + + /* Make sure progname does not fill the whole buffer */ + strlcat(buf, __progname, sizeof(buf) / 2 ); - /* truncate progname in case it is too long */ - buf[sizeof(buf) / 2] = '\0'; strlcat(buf, ": stack overflow in function ", sizeof buf); strlcat(buf, func, sizeof buf); |