diff options
| author | guenther <> | 2017-08-14 17:10:02 +0000 |
|---|---|---|
| committer | guenther <> | 2017-08-14 17:10:02 +0000 |
| commit | 0d9dde322788af6b4d822a974f73f44a857a950d (patch) | |
| tree | 3e1ddc4a996bd0460529473bc0609f4caa294b1a /src/lib/libc | |
| parent | 8f0579f75da4b74c2ea6fe1c4f874152f5602fbf (diff) | |
| download | openbsd-0d9dde322788af6b4d822a974f73f44a857a950d.tar.gz openbsd-0d9dde322788af6b4d822a974f73f44a857a950d.tar.bz2 openbsd-0d9dde322788af6b4d822a974f73f44a857a950d.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@
Diffstat (limited to 'src/lib/libc')
| -rw-r--r-- | src/lib/libc/string/memcpy.c | 15 |
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 | ||
| 47 | static 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 | ||
