1*1031c584SApple OSS Distributions /* 2*1031c584SApple OSS Distributions * Copyright (c) 2000-2006 Apple Computer, Inc. All rights reserved. 3*1031c584SApple OSS Distributions * 4*1031c584SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*1031c584SApple OSS Distributions * 6*1031c584SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*1031c584SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*1031c584SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*1031c584SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*1031c584SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*1031c584SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*1031c584SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*1031c584SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*1031c584SApple OSS Distributions * 15*1031c584SApple OSS Distributions * Please obtain a copy of the License at 16*1031c584SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*1031c584SApple OSS Distributions * 18*1031c584SApple OSS Distributions * The Original Code and all software distributed under the License are 19*1031c584SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*1031c584SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*1031c584SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*1031c584SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*1031c584SApple OSS Distributions * Please see the License for the specific language governing rights and 24*1031c584SApple OSS Distributions * limitations under the License. 25*1031c584SApple OSS Distributions * 26*1031c584SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*1031c584SApple OSS Distributions */ 28*1031c584SApple OSS Distributions /* 29*1031c584SApple OSS Distributions * NOTICE: This file was modified by McAfee Research in 2004 to introduce 30*1031c584SApple OSS Distributions * support for mandatory and extensible security protections. This notice 31*1031c584SApple OSS Distributions * is included in support of clause 2.2 (b) of the Apple Public License, 32*1031c584SApple OSS Distributions * Version 2.0. 33*1031c584SApple OSS Distributions */ 34*1031c584SApple OSS Distributions /* 35*1031c584SApple OSS Distributions * HISTORY 36*1031c584SApple OSS Distributions * @OSF_COPYRIGHT@ 37*1031c584SApple OSS Distributions */ 38*1031c584SApple OSS Distributions 39*1031c584SApple OSS Distributions #if (defined(__has_include) && __has_include(<__xnu_libcxx_sentinel.h>) && !defined(XNU_LIBCXX_SDKROOT)) 40*1031c584SApple OSS Distributions 41*1031c584SApple OSS Distributions #if !__has_include_next(<string.h>) 42*1031c584SApple OSS Distributions #error Do not build with -nostdinc (use GCC_USE_STANDARD_INCLUDE_SEARCHING=NO) 43*1031c584SApple OSS Distributions #endif /* !__has_include_next(<string.h>) */ 44*1031c584SApple OSS Distributions 45*1031c584SApple OSS Distributions #include_next <string.h> 46*1031c584SApple OSS Distributions 47*1031c584SApple OSS Distributions #else /* (defined(__has_include) && __has_include(<__xnu_libcxx_sentinel.h>) && !defined(XNU_LIBCXX_SDKROOT)) */ 48*1031c584SApple OSS Distributions 49*1031c584SApple OSS Distributions #ifndef _STRING_H_ 50*1031c584SApple OSS Distributions #define _STRING_H_ 1 51*1031c584SApple OSS Distributions 52*1031c584SApple OSS Distributions #ifdef MACH_KERNEL_PRIVATE 53*1031c584SApple OSS Distributions #include <types.h> 54*1031c584SApple OSS Distributions #else 55*1031c584SApple OSS Distributions #include <sys/types.h> 56*1031c584SApple OSS Distributions #endif 57*1031c584SApple OSS Distributions #include <sys/cdefs.h> 58*1031c584SApple OSS Distributions 59*1031c584SApple OSS Distributions __BEGIN_DECLS 60*1031c584SApple OSS Distributions 61*1031c584SApple OSS Distributions #ifndef NULL 62*1031c584SApple OSS Distributions #if defined (__cplusplus) 63*1031c584SApple OSS Distributions #if __cplusplus >= 201103L 64*1031c584SApple OSS Distributions #define NULL nullptr 65*1031c584SApple OSS Distributions #else 66*1031c584SApple OSS Distributions #define NULL 0 67*1031c584SApple OSS Distributions #endif 68*1031c584SApple OSS Distributions #else 69*1031c584SApple OSS Distributions #define NULL ((void *)0) 70*1031c584SApple OSS Distributions #endif 71*1031c584SApple OSS Distributions #endif 72*1031c584SApple OSS Distributions 73*1031c584SApple OSS Distributions /* 74*1031c584SApple OSS Distributions * Memory functions 75*1031c584SApple OSS Distributions * 76*1031c584SApple OSS Distributions * int bcmp(const void *s1, const void *s2, size_t n); 77*1031c584SApple OSS Distributions * int memcmp(const void *s1, const void *s2, size_t n); 78*1031c584SApple OSS Distributions * int timingsafe_bcmp(const void *b1, const void *b2, size_t n); 79*1031c584SApple OSS Distributions * 80*1031c584SApple OSS Distributions * void bzero(void *dst, size_t n); 81*1031c584SApple OSS Distributions * void *memset(void *s, int c, size_t n); 82*1031c584SApple OSS Distributions * int memset_s(void *s __sized_by(smax), size_t smax, int c, size_t n); 83*1031c584SApple OSS Distributions * 84*1031c584SApple OSS Distributions * void bcopy(const void *src, void *dst, size_t n); 85*1031c584SApple OSS Distributions * void *memcpy(void *dst, const void *src, size_t n); 86*1031c584SApple OSS Distributions * void *memove(void *dst, const void *src, size_t n); 87*1031c584SApple OSS Distributions * 88*1031c584SApple OSS Distributions * 89*1031c584SApple OSS Distributions * String functions 90*1031c584SApple OSS Distributions * 91*1031c584SApple OSS Distributions * size_t strlen(const char *s); 92*1031c584SApple OSS Distributions * size_t strnlen(const char *s, size_t n); 93*1031c584SApple OSS Distributions * 94*1031c584SApple OSS Distributions * int strcmp(const char *s1, const char *s2); 95*1031c584SApple OSS Distributions * int strncmp(const char *s1, const char *s2, size_t n); 96*1031c584SApple OSS Distributions * int strprefix(const char *s1, const char *s2) __stateful_pure; 97*1031c584SApple OSS Distributions * int strcasecmp(const char *s1, const char *s2); 98*1031c584SApple OSS Distributions * int strncasecmp(const char *s1, const char *s2, size_t n); 99*1031c584SApple OSS Distributions * 100*1031c584SApple OSS Distributions * char *strchr(const char *s, int c); 101*1031c584SApple OSS Distributions * char *strrchr(const char *s, int c); 102*1031c584SApple OSS Distributions * char *strnstr(const char *s, const char *find, size_t slen); 103*1031c584SApple OSS Distributions * 104*1031c584SApple OSS Distributions * size_t strlcpy(char *dst, const char *src, size_t n); 105*1031c584SApple OSS Distributions * size_t strlcat(char *dst, const char *src, size_t n); 106*1031c584SApple OSS Distributions */ 107*1031c584SApple OSS Distributions 108*1031c584SApple OSS Distributions 109*1031c584SApple OSS Distributions /* 110*1031c584SApple OSS Distributions * _FORTIFY_SOURCE > 0 will enable checked memory/string functions. 111*1031c584SApple OSS Distributions * 112*1031c584SApple OSS Distributions * _FORTIFY_SOURCE_STRICT will enable stricter checking (optional) 113*1031c584SApple OSS Distributions * for memcpy/memmove/bcopy and will check that copies do not go 114*1031c584SApple OSS Distributions * past the end of a struct member. 115*1031c584SApple OSS Distributions */ 116*1031c584SApple OSS Distributions #if KASAN 117*1031c584SApple OSS Distributions # define XNU_USE_CHK_BUILTIN(n) 0 118*1031c584SApple OSS Distributions # define XNU_USE_STRING_BUILTIN(n) 0 119*1031c584SApple OSS Distributions #elif defined (_FORTIFY_SOURCE) && _FORTIFY_SOURCE == 0 120*1031c584SApple OSS Distributions # define XNU_USE_CHK_BUILTIN(n) 0 121*1031c584SApple OSS Distributions # define XNU_USE_STRING_BUILTIN(n) __has_builtin(__builtin_##n) 122*1031c584SApple OSS Distributions #elif __has_ptrcheck 123*1031c584SApple OSS Distributions # define XNU_USE_CHK_BUILTIN(n) 0 124*1031c584SApple OSS Distributions # define XNU_USE_STRING_BUILTIN(n) __has_builtin(__builtin_##n) 125*1031c584SApple OSS Distributions #elif defined(__cplusplus) && __has_include(<__xnu_libcxx_sentinel.h>) 126*1031c584SApple OSS Distributions # define XNU_USE_CHK_BUILTIN(n) 0 127*1031c584SApple OSS Distributions # define XNU_USE_STRING_BUILTIN(n) 0 128*1031c584SApple OSS Distributions #elif XNU_KERNEL_PRIVATE || defined(_FORTIFY_SOURCE_STRICT) 129*1031c584SApple OSS Distributions # define XNU_USE_CHK_BUILTIN(n) __has_builtin(__builtin___##n##_chk) 130*1031c584SApple OSS Distributions # define XNU_USE_STRING_BUILTIN(n) __has_builtin(__builtin_##n) 131*1031c584SApple OSS Distributions # define __xnu_bos_default(ptr) __xnu_bos_strict(ptr) 132*1031c584SApple OSS Distributions #else 133*1031c584SApple OSS Distributions # define XNU_USE_CHK_BUILTIN(n) __has_builtin(__builtin___##n##_chk) 134*1031c584SApple OSS Distributions # define XNU_USE_STRING_BUILTIN(n) __has_builtin(__builtin_##n) 135*1031c584SApple OSS Distributions # define __xnu_bos_default(ptr) __xnu_bos_loose(ptr) 136*1031c584SApple OSS Distributions #endif 137*1031c584SApple OSS Distributions 138*1031c584SApple OSS Distributions #if __has_builtin(__builtin_dynamic_object_size) 139*1031c584SApple OSS Distributions # define __xnu_bos_loose(ptr) __builtin_dynamic_object_size(ptr, 0) 140*1031c584SApple OSS Distributions # define __xnu_bos_strict(ptr) __builtin_dynamic_object_size(ptr, 1) 141*1031c584SApple OSS Distributions #else 142*1031c584SApple OSS Distributions # define __xnu_bos_loose(ptr) __builtin_object_size(ptr, 0) 143*1031c584SApple OSS Distributions # define __xnu_bos_strict(ptr) __builtin_object_size(ptr, 1) 144*1031c584SApple OSS Distributions #endif 145*1031c584SApple OSS Distributions 146*1031c584SApple OSS Distributions 147*1031c584SApple OSS Distributions #pragma mark memory functions 148*1031c584SApple OSS Distributions 149*1031c584SApple OSS Distributions extern int bcmp(const void *s1 __sized_by(n), const void *s2 __sized_by(n), size_t n) __stateful_pure; 150*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(bcmp) 151*1031c584SApple OSS Distributions #define bcmp(s1, s2, n) __builtin_bcmp(s1, s2, n) 152*1031c584SApple OSS Distributions #endif 153*1031c584SApple OSS Distributions 154*1031c584SApple OSS Distributions 155*1031c584SApple OSS Distributions extern int memcmp(const void *s1 __sized_by(n), const void *s2 __sized_by(n), size_t n) __stateful_pure; 156*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(memcmp) 157*1031c584SApple OSS Distributions #define memcmp(s1, s2, n) __builtin_memcmp(s1, s2, n) 158*1031c584SApple OSS Distributions #endif 159*1031c584SApple OSS Distributions 160*1031c584SApple OSS Distributions 161*1031c584SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE 162*1031c584SApple OSS Distributions /* 163*1031c584SApple OSS Distributions * memcmp_zero_ptr_aligned() checks string s of n bytes contains all zeros. 164*1031c584SApple OSS Distributions * Address and size of the string s must be pointer-aligned. 165*1031c584SApple OSS Distributions * Return 0 if true, 1 otherwise. Also return 0 if n is 0. 166*1031c584SApple OSS Distributions */ 167*1031c584SApple OSS Distributions extern unsigned long memcmp_zero_ptr_aligned(const void *s __sized_by(n), size_t n) __stateful_pure; 168*1031c584SApple OSS Distributions #endif 169*1031c584SApple OSS Distributions 170*1031c584SApple OSS Distributions 171*1031c584SApple OSS Distributions extern int timingsafe_bcmp(const void *b1 __sized_by(n), const void *b2 __sized_by(n), size_t n); 172*1031c584SApple OSS Distributions 173*1031c584SApple OSS Distributions 174*1031c584SApple OSS Distributions extern void bzero(void *s __sized_by(n), size_t n); 175*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(bzero) 176*1031c584SApple OSS Distributions #define bzero(s, n) __builtin_bzero(s, n) 177*1031c584SApple OSS Distributions #endif 178*1031c584SApple OSS Distributions 179*1031c584SApple OSS Distributions 180*1031c584SApple OSS Distributions extern void *memset(void *s __sized_by(n), int c, size_t n); 181*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(memset) && XNU_KERNEL_PRIVATE /* rdar://103270898&103281379 */ 182*1031c584SApple OSS Distributions #define memset(s, c, n) __builtin___memset_chk(s, c, n, __xnu_bos_default(s)) 183*1031c584SApple OSS Distributions #elif XNU_USE_STRING_BUILTIN(memset) && XNU_KERNEL_PRIVATE 184*1031c584SApple OSS Distributions #define memset(s, c, n) __builtin_memset(s, c, n) 185*1031c584SApple OSS Distributions #endif 186*1031c584SApple OSS Distributions 187*1031c584SApple OSS Distributions 188*1031c584SApple OSS Distributions extern int memset_s(void *s __sized_by(smax), size_t smax, int c, size_t n); 189*1031c584SApple OSS Distributions 190*1031c584SApple OSS Distributions 191*1031c584SApple OSS Distributions extern void *memcpy(void *dst __sized_by(n), const void *src __sized_by(n), size_t n); 192*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(memcpy) 193*1031c584SApple OSS Distributions #define memcpy(dst, src, n) __builtin___memcpy_chk(dst, src, n, __xnu_bos_default(dst)) 194*1031c584SApple OSS Distributions #define __nochk_memcpy(dst, src, n) __builtin___memcpy_chk(dst, src, n, __xnu_bos_loose(dst)) 195*1031c584SApple OSS Distributions #elif XNU_USE_STRING_BUILTIN(memcpy) 196*1031c584SApple OSS Distributions #define memcpy(dst, src, n) __builtin_memcpy(dst, src, n) 197*1031c584SApple OSS Distributions #define __nochk_memcpy(dst, src, n) memcpy(dst, src, n) 198*1031c584SApple OSS Distributions #else 199*1031c584SApple OSS Distributions #define __nochk_memcpy(dst, src, n) memcpy(dst, src, n) 200*1031c584SApple OSS Distributions #endif 201*1031c584SApple OSS Distributions 202*1031c584SApple OSS Distributions 203*1031c584SApple OSS Distributions extern void *memmove(void *dst __sized_by(n), const void *src __sized_by(n), size_t n); 204*1031c584SApple OSS Distributions extern void bcopy(const void *src __sized_by(n), void *dst __sized_by(n), size_t n); 205*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(memmove) 206*1031c584SApple OSS Distributions #define memmove(dst, src, n) __builtin___memmove_chk(dst, src, n, __xnu_bos_default(dst)) 207*1031c584SApple OSS Distributions #define bcopy(src, dst, n) __builtin___memmove_chk(dst, src, n, __xnu_bos_default(dst)) 208*1031c584SApple OSS Distributions #define __nochk_memmove(dst, src, n) __builtin___memmove_chk(dst, src, n, __xnu_bos_loose(dst)) 209*1031c584SApple OSS Distributions #define __nochk_bcopy(src, dst, n) __builtin___memmove_chk(dst, src, n, __xnu_bos_loose(dst)) 210*1031c584SApple OSS Distributions #elif XNU_USE_STRING_BUILTIN(memmove) 211*1031c584SApple OSS Distributions #define memmove(dst, src, n) __builtin_memmove(dst, src, n) 212*1031c584SApple OSS Distributions #define bcopy(src, dst, n) __builtin_memmove(dst, src, n) 213*1031c584SApple OSS Distributions #define __nochk_memmove(dst, src, n) memmove(dst, src, n) 214*1031c584SApple OSS Distributions #define __nochk_bcopy(src, dst, n) bcopy(src, dst, n) 215*1031c584SApple OSS Distributions #else 216*1031c584SApple OSS Distributions #define __nochk_memmove(dst, src, n) memmove(dst, src, n) 217*1031c584SApple OSS Distributions #define __nochk_bcopy(src, dst, n) bcopy(src, dst, n) 218*1031c584SApple OSS Distributions #endif /* !XNU_USE_CHK_BUILTIN(memmove) */ 219*1031c584SApple OSS Distributions 220*1031c584SApple OSS Distributions 221*1031c584SApple OSS Distributions #pragma mark string functions 222*1031c584SApple OSS Distributions 223*1031c584SApple OSS Distributions extern size_t strlen(const char *__null_terminated s) __stateful_pure; 224*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strlen) 225*1031c584SApple OSS Distributions #define strlen(s) __builtin_strlen(s) 226*1031c584SApple OSS Distributions #endif 227*1031c584SApple OSS Distributions 228*1031c584SApple OSS Distributions 229*1031c584SApple OSS Distributions extern size_t strnlen(const char *__null_terminated s, size_t n) __stateful_pure; 230*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strnlen) 231*1031c584SApple OSS Distributions #define strnlen(s, n) __builtin_strnlen(s, n) 232*1031c584SApple OSS Distributions #endif 233*1031c584SApple OSS Distributions 234*1031c584SApple OSS Distributions 235*1031c584SApple OSS Distributions extern int strcmp(const char *__null_terminated s1, const char *__null_terminated s2) __stateful_pure; 236*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strcmp) 237*1031c584SApple OSS Distributions #define strcmp(s1, s2) __builtin_strcmp(s1, s2) 238*1031c584SApple OSS Distributions #endif 239*1031c584SApple OSS Distributions 240*1031c584SApple OSS Distributions 241*1031c584SApple OSS Distributions extern int strncmp(const char *__null_terminated s1, const char *__null_terminated s2, size_t n) __stateful_pure; 242*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strncmp) 243*1031c584SApple OSS Distributions #define strncmp(s1, s2, n) __builtin_strncmp(s1, s2, n) 244*1031c584SApple OSS Distributions #endif 245*1031c584SApple OSS Distributions 246*1031c584SApple OSS Distributions 247*1031c584SApple OSS Distributions extern int strprefix(const char *__null_terminated s1, const char *__null_terminated s2) __stateful_pure; 248*1031c584SApple OSS Distributions 249*1031c584SApple OSS Distributions 250*1031c584SApple OSS Distributions extern int strcasecmp(const char *__null_terminated s1, const char *__null_terminated s2) __stateful_pure; 251*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strcasecmp) 252*1031c584SApple OSS Distributions #define strcasecmp(s1, s2) __builtin_strcasecmp(s1, s2) 253*1031c584SApple OSS Distributions #endif 254*1031c584SApple OSS Distributions 255*1031c584SApple OSS Distributions 256*1031c584SApple OSS Distributions extern int strncasecmp(const char *__null_terminated s1, const char *__null_terminated s2, size_t n) __stateful_pure; 257*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strncasecmp) 258*1031c584SApple OSS Distributions #define strncasecmp(s1, s2, n) __builtin_strncasecmp(s1, s2, n) 259*1031c584SApple OSS Distributions #endif 260*1031c584SApple OSS Distributions 261*1031c584SApple OSS Distributions 262*1031c584SApple OSS Distributions extern char *__null_terminated strchr(const char *__null_terminated s, int c) __stateful_pure; 263*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strchr) && !__has_ptrcheck /* rdar://103265304 */ 264*1031c584SApple OSS Distributions #define strchr(s, c) __builtin_strchr(s, c) 265*1031c584SApple OSS Distributions #endif 266*1031c584SApple OSS Distributions 267*1031c584SApple OSS Distributions 268*1031c584SApple OSS Distributions #if XNU_KERNEL_PRIVATE /* rdar://103276672 */ 269*1031c584SApple OSS Distributions extern char *__null_terminated strrchr(const char *__null_terminated s, int c) __stateful_pure; 270*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strrchr) && !__has_ptrcheck /* rdar://103265304 */ 271*1031c584SApple OSS Distributions #define strrchr(s, c) __builtin_strrchr(s, c) 272*1031c584SApple OSS Distributions #endif 273*1031c584SApple OSS Distributions #endif 274*1031c584SApple OSS Distributions 275*1031c584SApple OSS Distributions 276*1031c584SApple OSS Distributions extern char *__null_terminated strnstr(const char *__null_terminated s, const char *__null_terminated find, size_t slen) __stateful_pure; 277*1031c584SApple OSS Distributions #if XNU_USE_STRING_BUILTIN(strnstr) && !__has_ptrcheck /* rdar://103265304 */ 278*1031c584SApple OSS Distributions #define strnstr(s, find, slen) __builtin_strnstr(s, find, slen) 279*1031c584SApple OSS Distributions #endif 280*1031c584SApple OSS Distributions 281*1031c584SApple OSS Distributions 282*1031c584SApple OSS Distributions extern size_t strlcpy(char *__sized_by(n) dst, const char *__null_terminated src, size_t n); 283*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(strlcpy) 284*1031c584SApple OSS Distributions #define strlcpy(dst, src, n) __builtin___strlcpy_chk(dst, src, n, __xnu_bos_strict(dst)) 285*1031c584SApple OSS Distributions #elif XNU_USE_STRING_BUILTIN(strlcpy) 286*1031c584SApple OSS Distributions #define strlcpy(dst, src, n) __builtin_strlcpy(dst, src, n) 287*1031c584SApple OSS Distributions #endif 288*1031c584SApple OSS Distributions 289*1031c584SApple OSS Distributions 290*1031c584SApple OSS Distributions extern size_t strlcat(char *__sized_by(n) dst, const char *__null_terminated src, size_t n); 291*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(strlcat) 292*1031c584SApple OSS Distributions #define strlcat(dst, src, n) __builtin___strlcat_chk(dst, src, n, __xnu_bos_strict(dst)) 293*1031c584SApple OSS Distributions #elif XNU_USE_STRING_BUILTIN(strlcat) 294*1031c584SApple OSS Distributions #define strlcat(dst, src, n) __builtin_strlcat(dst, src, n) 295*1031c584SApple OSS Distributions #endif 296*1031c584SApple OSS Distributions 297*1031c584SApple OSS Distributions 298*1031c584SApple OSS Distributions #pragma mark deprecated functions 299*1031c584SApple OSS Distributions #if !__has_ptrcheck 300*1031c584SApple OSS Distributions 301*1031c584SApple OSS Distributions /* 302*1031c584SApple OSS Distributions * char *strncat(char *dst, const char *src, size_t n); 303*1031c584SApple OSS Distributions * char *strncpy(char *dst, const char *src, size_t n); 304*1031c584SApple OSS Distributions * 305*1031c584SApple OSS Distributions * char *strcat(char *dst, const char *src); 306*1031c584SApple OSS Distributions * char *strcpy(char *, const char *); 307*1031c584SApple OSS Distributions * 308*1031c584SApple OSS Distributions * char *STRDUP(const char *, int); 309*1031c584SApple OSS Distributions */ 310*1031c584SApple OSS Distributions 311*1031c584SApple OSS Distributions __deprecated_msg("use strlcat") 312*1031c584SApple OSS Distributions __kpi_deprecated_arm64_macos_unavailable 313*1031c584SApple OSS Distributions extern char *strncat(char *dst, const char *src, size_t n); 314*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(strncat) 315*1031c584SApple OSS Distributions #define strncat(dst, src, n) __builtin___strncat_chk(dst, src, n, __xnu_bos_strict(dst)) 316*1031c584SApple OSS Distributions #endif 317*1031c584SApple OSS Distributions 318*1031c584SApple OSS Distributions 319*1031c584SApple OSS Distributions __deprecated_msg("use strlcpy") 320*1031c584SApple OSS Distributions __kpi_deprecated_arm64_macos_unavailable 321*1031c584SApple OSS Distributions extern char *strncpy(char *dst, const char *src, size_t n); 322*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(strncpy) 323*1031c584SApple OSS Distributions #define strncpy(dst, src, n) __builtin___strncpy_chk(dst, src, n, __xnu_bos_strict(dst)) 324*1031c584SApple OSS Distributions #endif 325*1031c584SApple OSS Distributions 326*1031c584SApple OSS Distributions __deprecated_msg("use strlcpy") 327*1031c584SApple OSS Distributions __kpi_deprecated_arm64_macos_unavailable 328*1031c584SApple OSS Distributions extern char *strcpy(char *, const char *); 329*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(strcpy) 330*1031c584SApple OSS Distributions /* rdar://103287225 */ 331*1031c584SApple OSS Distributions #define strcpy(dst, src, len) __builtin___strcpy_chk(dst, src, __xnu_bos_strict(dst)) 332*1031c584SApple OSS Distributions #endif 333*1031c584SApple OSS Distributions 334*1031c584SApple OSS Distributions __deprecated_msg("use strlcat") 335*1031c584SApple OSS Distributions __kpi_deprecated_arm64_macos_unavailable 336*1031c584SApple OSS Distributions extern char *strcat(char *dst, const char *src); 337*1031c584SApple OSS Distributions #if XNU_USE_CHK_BUILTIN(strcat) 338*1031c584SApple OSS Distributions #define strcat(dst, src) __builtin___strcat_chk(dst, src, __xnu_bos_strict(dst)) 339*1031c584SApple OSS Distributions #endif 340*1031c584SApple OSS Distributions 341*1031c584SApple OSS Distributions #if XNU_PLATFORM_MacOSX 342*1031c584SApple OSS Distributions #ifndef KERNEL_PRIVATE 343*1031c584SApple OSS Distributions extern char *STRDUP(const char *, int); 344*1031c584SApple OSS Distributions #endif 345*1031c584SApple OSS Distributions #endif /* XNU_PLATFORM_MacOSX */ 346*1031c584SApple OSS Distributions 347*1031c584SApple OSS Distributions #endif /* !__has_ptrcheck */ 348*1031c584SApple OSS Distributions 349*1031c584SApple OSS Distributions #if __has_include(<san/memintrinsics.h>) 350*1031c584SApple OSS Distributions #include <san/memintrinsics.h> 351*1031c584SApple OSS Distributions #endif 352*1031c584SApple OSS Distributions 353*1031c584SApple OSS Distributions __END_DECLS 354*1031c584SApple OSS Distributions 355*1031c584SApple OSS Distributions #endif /* _STRING_H_ */ 356*1031c584SApple OSS Distributions 357*1031c584SApple OSS Distributions #endif 358