summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCan Erkin Acar <canacar@cvs.openbsd.org>2015-12-01 17:05:26 +0000
committerCan Erkin Acar <canacar@cvs.openbsd.org>2015-12-01 17:05:26 +0000
commit3b451ef3112b9076f2de2dbee576eb162e602851 (patch)
tree854697103e6deade9df6658057342abee62b6223
parentc0a66ce2ecc8c690235237a0d10111d8c6f92695 (diff)
use strlcat instead of strlcpy with modified arguments. ok deraadt@
-rw-r--r--lib/libc/sys/stack_protector.c11
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);