Loading...
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | // workaround in case we accidentally grab this project's <sys/cdefs.h> #define _LIBC_NO_FEATURE_VERIFICATION 1 #include <sys/cdefs.h> #ifdef UNDEF_BOUNDS_SAFETY_ATTRIBUTES #undef __LIBC_STAGED_BOUNDS_SAFETY_ATTRIBUTE #endif #ifdef _TEST_POSIX_C_SOURCE #undef _POSIX_C_SOURCE #define _POSIX_C_SOURCE _TEST_POSIX_C_SOURCE #endif #ifdef _TEST_DARWIN_C_LEVEL #undef __DARWIN_C_LEVEL #define __DARWIN_C_LEVEL _TEST_DARWIN_C_LEVEL #endif /* This file is preprocessed with the following feature combinations: POSIX_C_SOURCE DARWIN_C_LEVEL UNIFDEF_DRIVERKIT -fbounds-safety - 0 - - - 200112L - - - 200809L - - - __DARWIN_C_FULL - - 0 __DARWIN_C_FULL - - - __DARWIN_C_FULL 1 - - __DARWIN_C_FULL - 1 - __DARWIN_C_FULL 1 1 */ #include <string.h> #include <stdio.h> extern void undefined; // MARK: - <strings.h> safe functions #ifndef bcopy #define bcopy(...) undefined #endif #ifndef bzero #define bzero(...) undefined #endif // MARK: - <stdio.h> safe functions #ifndef sprintf #define sprintf(...) undefined #endif #ifndef vsprintf #define vsprintf(...) undefined #endif #ifndef snprintf #define snprintf(...) undefined #endif #ifndef vsnprintf #define vsnprintf(...) undefined #endif // MARK: - <string.h> safe functions #ifndef memccpy #define memccpy(...) undefined #endif #ifndef memcpy #define memcpy(...) undefined #endif #ifndef memmove #define memmove(...) undefined #endif #ifndef memset #define memset(...) undefined #endif #ifndef strcpy #define strcpy(...) undefined #endif #ifndef strcat #define strcat(...) undefined #endif #ifndef strncpy #define strncpy(...) undefined #endif #ifndef strncat #define strncat(...) undefined #endif #ifndef stpcpy #define stpcpy(...) undefined #endif #ifndef stpncpy #define stpncpy(...) undefined #endif #ifndef strlcpy #define strlcpy(...) undefined #endif #ifndef strlcat #define strlcat(...) undefined #endif #define HELLO_SIZEOF_RESULT() "hello", sizeof(result) void test_stdio(va_list ap) { char result[100]; const char hello[] = "hello"; const char world[] = " world"; test_bcopy: bcopy(hello, result, 6); test_bzero: bzero(result, sizeof(result)); test_sprintf: sprintf(result, "hello %s!", "Darwin"); test_vsprintf: vsprintf(result, "hello %s!", ap); test_snprintf: snprintf(result, sizeof(result), "hello %s!", "Darwin"); test_vsnprintf: vsnprintf(result, sizeof(result), "hello %s!", ap); test_memccpy: memccpy(result, hello, 0, 6); test_memcpy: memcpy(result, hello, 6); test_memmove: memmove(result, hello, 6); test_memset: memset(result, 0, sizeof(result)); test_strcpy: strcpy(result, hello); test_strcat: strcat(result, world); test_strncpy: strncpy(result, HELLO_SIZEOF_RESULT()); test_strncat: strncat(result, world, 10); test_stpcpy: stpcpy(result, hello); test_stpncpy: stpncpy(result, hello, 10); test_strlcpy: strlcpy(result, HELLO_SIZEOF_RESULT()); test_strlcat: strlcat(result, HELLO_SIZEOF_RESULT()); } |