summaryrefslogtreecommitdiff
path: root/lib/libc
diff options
context:
space:
mode:
authorPhilip Guenther <guenther@cvs.openbsd.org>2017-08-14 17:10:03 +0000
committerPhilip Guenther <guenther@cvs.openbsd.org>2017-08-14 17:10:03 +0000
commit4ab4fdb28f098fc700cdf2b92f7c61f2f633030e (patch)
tree55358b5a17f97ceea0a89a87df5a4d58e236a333 /lib/libc
parentc1e690413040832a95dcd27d0bd6a4b1359da58d (diff)
Use sendsyslog() directly instead of syslog_r() for the "backwards memcpy"
messages, to avoid pulling in piles of other machinery unnecessarily problem observed by schwarze@ ok deraadt@ millert@
Diffstat (limited to 'lib/libc')
-rw-r--r--lib/libc/string/memcpy.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/lib/libc/string/memcpy.c b/lib/libc/string/memcpy.c
index 73136edd722..a2516ed041a 100644
--- a/lib/libc/string/memcpy.c
+++ b/lib/libc/string/memcpy.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: memcpy.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */
+/* $OpenBSD: memcpy.c,v 1.3 2017/08/14 17:10:02 guenther Exp $ */
/*-
* Copyright (c) 1990 The Regents of the University of California.
* All rights reserved.
@@ -44,6 +44,8 @@ typedef long word; /* "word" used for optimal copy speed */
#define wsize sizeof(word)
#define wmask (wsize - 1)
+static const char backwards_msg[] = ": backwards memcpy";
+
/*
* Copy a block of memory, not handling overlap.
*/
@@ -59,9 +61,16 @@ memcpy(void *dst0, const void *src0, size_t length)
if ((dst < src && dst + length > src) ||
(src < dst && src + length > dst)) {
- struct syslog_data sdata = SYSLOG_DATA_INIT;
+ char buf[1024];
+
+ /* <10> is LOG_CRIT */
+ strlcpy(buf, "<10>", sizeof buf);
+
+ /* Make sure progname does not fill the whole buffer */
+ strlcat(buf, __progname, sizeof(buf) - sizeof backwards_msg);
+ strlcat(buf, backwards_msg, sizeof buf);
- syslog_r(LOG_CRIT, &sdata, "backwards memcpy");
+ sendsyslog(buf, strlen(buf), LOG_CONS);
abort();
}