X-Git-Url: https://git.saurik.com/apple/libc.git/blobdiff_plain/224c70764cab4e0e39a26aaf3ad3016552f62f55..6465356a983ac139f81d3b7913cdb548477c346c:/secure/memcpy_chk.c diff --git a/secure/memcpy_chk.c b/secure/memcpy_chk.c index 6f2e06b..bb286fa 100644 --- a/secure/memcpy_chk.c +++ b/secure/memcpy_chk.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007 Apple Inc. All rights reserved. + * Copyright (c) 2007-2013 Apple Inc. All rights reserved. * * @APPLE_LICENSE_HEADER_START@ * @@ -23,14 +23,19 @@ #include #include - -extern void __chk_fail (void) __attribute__((__noreturn__)); +#include "secure.h" void * __memcpy_chk (void *dest, const void *src, size_t len, size_t dstlen) { if (__builtin_expect (dstlen < len, 0)) - __chk_fail (); + __chk_fail_overflow (); + + /* On OS X, memcpy has supported overlapping buffers for many years. + * While technically, this will catch buggy code, we should not abort. + * if (__chk_assert_no_overlap) + * __chk_overlap(dest, len, src, len); + */ return memcpy (dest, src, len); }