From f3645329ae3b69b0d7c96a715623ff9763f6a7fe Mon Sep 17 00:00:00 2001 From: guenther <> Date: Mon, 14 Aug 2017 17:10:02 +0000 Subject: [PATCH] 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@ --- src/lib/libc/string/memcpy.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/lib/libc/string/memcpy.c b/src/lib/libc/string/memcpy.c index 73136edd..a2516ed0 100644 --- a/src/lib/libc/string/memcpy.c +++ b/src/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(); }