|
| 1 | +typedef unsigned long long size_t; |
| 2 | +void *memset(void *s, int c, unsigned long n); |
| 3 | +void *__builtin_memset(void *s, int c, unsigned long n); |
| 4 | +typedef int errno_t; |
| 5 | +typedef unsigned int rsize_t; |
| 6 | +errno_t memset_s(void *dest, rsize_t destsz, int ch, rsize_t count); |
| 7 | +char *strcpy(char *dest, const char *src); |
| 8 | + |
| 9 | +extern void use_pw(char *pw); |
| 10 | + |
| 11 | +#define PW_SIZE 32 |
| 12 | + |
| 13 | +// x86-64 gcc 9.2: deleted |
| 14 | +// x86-64 clang 9.0.0: deleted |
| 15 | +// x64 msvc v19.14 (WINE): deleted |
| 16 | +int func1(void) { |
| 17 | + char pw1[PW_SIZE]; |
| 18 | + use_pw(pw1); |
| 19 | + memset(pw1, 0, PW_SIZE); // BAD [NOT DETECTED] |
| 20 | + return 0; |
| 21 | +} |
| 22 | + |
| 23 | +// x86-64 gcc 9.2: deleted |
| 24 | +// x86-64 clang 9.0.0: deleted |
| 25 | +// x64 msvc v19.14 (WINE): not deleted |
| 26 | +int func1a(void) { |
| 27 | + char pw1a[PW_SIZE]; |
| 28 | + use_pw(pw1a); |
| 29 | + __builtin_memset(pw1a, 0, PW_SIZE); // BAD [NOT DETECTED] |
| 30 | + return 0; |
| 31 | +} |
| 32 | + |
| 33 | +// x86-64 gcc 9.2: deleted |
| 34 | +// x86-64 clang 9.0.0: deleted |
| 35 | +// x64 msvc v19.14 (WINE): deleted |
| 36 | +char *func1b(void) { |
| 37 | + char pw1b[PW_SIZE]; |
| 38 | + use_pw(pw1b); |
| 39 | + memset(pw1b, 0, PW_SIZE); // BAD [NOT DETECTED] |
| 40 | + pw1b[0] = pw1b[3] = 'a'; |
| 41 | + return 0; |
| 42 | +} |
| 43 | + |
| 44 | +// x86-64 gcc 9.2: not deleted |
| 45 | +// x86-64 clang 9.0.0: not deleted |
| 46 | +// x64 msvc v19.14 (WINE): not deleted |
| 47 | +int func1c(char pw1c[PW_SIZE]) { |
| 48 | + use_pw(pw1c); |
| 49 | + memset(pw1c, 0, PW_SIZE); // GOOD |
| 50 | + return 0; |
| 51 | +} |
| 52 | + |
| 53 | +// x86-64 gcc 9.2: not deleted |
| 54 | +// x86-64 clang 9.0.0: not deleted |
| 55 | +// x64 msvc v19.14 (WINE): not deleted |
| 56 | +char pw1d[PW_SIZE]; |
| 57 | +int func1d() { |
| 58 | + use_pw(pw1d); |
| 59 | + memset(pw1d, 0, PW_SIZE); // GOOD |
| 60 | + return 0; |
| 61 | +} |
| 62 | +// x86-64 gcc 9.2: not deleted |
| 63 | +// x86-64 clang 9.0.0: not deleted |
| 64 | +// x64 msvc v19.14 (WINE): not deleted |
| 65 | +char *func2(void) { |
| 66 | + char pw2[PW_SIZE]; |
| 67 | + use_pw(pw2); |
| 68 | + memset(pw2, 1, PW_SIZE); // BAD [NOT DETECTED] |
| 69 | + return pw2; |
| 70 | +} |
| 71 | + |
| 72 | +// x86-64 gcc 9.2: deleted |
| 73 | +// x86-64 clang 9.0.0: deleted |
| 74 | +// x64 msvc v19.14 (WINE): partially deleted |
| 75 | +int func3(void) { |
| 76 | + char pw3[PW_SIZE]; |
| 77 | + use_pw(pw3); |
| 78 | + memset(pw3, 4, PW_SIZE); // BAD [NOT DETECTED] |
| 79 | + return pw3[2]; |
| 80 | +} |
| 81 | + |
| 82 | +// x86-64 gcc 9.2: deleted |
| 83 | +// x86-64 clang 9.0.0: deleted |
| 84 | +// x64 msvc v19.14 (WINE): not deleted |
| 85 | +int func4(void) { |
| 86 | + char pw1a[PW_SIZE]; |
| 87 | + use_pw(pw1a); |
| 88 | + __builtin_memset(pw1a + 3, 0, PW_SIZE - 3); // BAD [NOT DETECTED] |
| 89 | + return 0; |
| 90 | +} |
| 91 | + |
| 92 | +// x86-64 gcc 9.2: deleted |
| 93 | +// x86-64 clang 9.0.0: deleted |
| 94 | +// x64 msvc v19.14 (WINE): not deleted |
| 95 | +int func6(void) { |
| 96 | + char pw1a[PW_SIZE]; |
| 97 | + use_pw(pw1a); |
| 98 | + __builtin_memset(&pw1a[3], 0, PW_SIZE - 3); // BAD [NOT DETECTED] |
| 99 | + return pw1a[2]; |
| 100 | +} |
| 101 | + |
| 102 | +// x86-64 gcc 9.2: deleted |
| 103 | +// x86-64 clang 9.0.0: deleted |
| 104 | +// x64 msvc v19.14 (WINE): not deleted |
| 105 | +int func5(void) { |
| 106 | + char pw1a[PW_SIZE]; |
| 107 | + use_pw(pw1a); |
| 108 | + __builtin_memset(pw1a + 3, 0, PW_SIZE - 4); // GOOD |
| 109 | + return pw1a[4]; |
| 110 | +} |
| 111 | + |
| 112 | +// x86-64 gcc 9.2: deleted |
| 113 | +// x86-64 clang 9.0.0: deleted |
| 114 | +// x64 msvc v19.14 (WINE): not deleted |
| 115 | +int func7(void) { |
| 116 | + char pw1a[PW_SIZE]; |
| 117 | + use_pw(pw1a); |
| 118 | + __builtin_memset(&pw1a[3], 0, PW_SIZE - 5); // BAD [NOT DETECTED] |
| 119 | + return 0; |
| 120 | +} |
| 121 | + |
| 122 | +// x86-64 gcc 9.2: not deleted |
| 123 | +// x86-64 clang 9.0.0: not deleted |
| 124 | +// x64 msvc v19.14 (WINE): not deleted |
| 125 | +int func8(void) { |
| 126 | + char pw1a[PW_SIZE]; |
| 127 | + use_pw(pw1a); |
| 128 | + __builtin_memset(pw1a + pw1a[3], 0, PW_SIZE - 4); // GOOD |
| 129 | + return pw1a[4]; |
| 130 | +} |
| 131 | + |
| 132 | +// x86-64 gcc 9.2: not deleted |
| 133 | +// x86-64 clang 9.0.0: not deleted |
| 134 | +// x64 msvc v19.14 (WINE): not deleted |
| 135 | +char *func9(void) { |
| 136 | + char pw1[PW_SIZE]; |
| 137 | + use_pw(pw1); |
| 138 | + memset(pw1, 0, PW_SIZE); // BAD [NOT DETECTED] |
| 139 | + return 0; |
| 140 | +} |
0 commit comments