summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorguenther <>2017-08-14 17:10:02 +0000
committerguenther <>2017-08-14 17:10:02 +0000
commit037380a6241095814abcee8e70fc14d1638c07d3 (patch)
tree3e1ddc4a996bd0460529473bc0609f4caa294b1a
parent0754fa6e75d136097f069184fec34c39ad192df9 (diff)
downloadopenbsd-037380a6241095814abcee8e70fc14d1638c07d3.tar.gz
openbsd-037380a6241095814abcee8e70fc14d1638c07d3.tar.bz2
openbsd-037380a6241095814abcee8e70fc14d1638c07d3.zip
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@
-rw-r--r--src/lib/libc/string/memcpy.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/lib/libc/string/memcpy.c b/src/lib/libc/string/memcpy.c
index 73136edd72..a2516ed041 100644
--- a/src/lib/libc/string/memcpy.c
+++ b/src/lib/libc/string/memcpy.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: memcpy.c,v 1.2 2015/08/31 02:53:57 guenther Exp $ */ 1/* $OpenBSD: memcpy.c,v 1.3 2017/08/14 17:10:02 guenther Exp $ */
2/*- 2/*-
3 * Copyright (c) 1990 The Regents of the University of California. 3 * Copyright (c) 1990 The Regents of the University of California.
4 * All rights reserved. 4 * All rights reserved.
@@ -44,6 +44,8 @@ typedef long word; /* "word" used for optimal copy speed */
44#define wsize sizeof(word) 44#define wsize sizeof(word)
45#define wmask (wsize - 1) 45#define wmask (wsize - 1)
46 46
47static const char backwards_msg[] = ": backwards memcpy";
48
47/* 49/*
48 * Copy a block of memory, not handling overlap. 50 * Copy a block of memory, not handling overlap.
49 */ 51 */
@@ -59,9 +61,16 @@ memcpy(void *dst0, const void *src0, size_t length)
59 61
60 if ((dst < src && dst + length > src) || 62 if ((dst < src && dst + length > src) ||
61 (src < dst && src + length > dst)) { 63 (src < dst && src + length > dst)) {
62 struct syslog_data sdata = SYSLOG_DATA_INIT; 64 char buf[1024];
65
66 /* <10> is LOG_CRIT */
67 strlcpy(buf, "<10>", sizeof buf);
68
69 /* Make sure progname does not fill the whole buffer */
70 strlcat(buf, __progname, sizeof(buf) - sizeof backwards_msg);
71 strlcat(buf, backwards_msg, sizeof buf);
63 72
64 syslog_r(LOG_CRIT, &sdata, "backwards memcpy"); 73 sendsyslog(buf, strlen(buf), LOG_CONS);
65 abort(); 74 abort();
66 } 75 }
67 76