1 |
149 |
jeremybenn |
#ifndef os
|
2 |
|
|
# define os(ptr) __builtin_object_size (ptr, 0)
|
3 |
|
|
#endif
|
4 |
|
|
|
5 |
|
|
/* This is one of the alternatives for object size checking.
|
6 |
|
|
If dst has side-effects, size checking will never be done. */
|
7 |
|
|
#undef memcpy
|
8 |
|
|
#define memcpy(dst, src, len) \
|
9 |
|
|
__builtin___memcpy_chk (dst, src, len, os (dst))
|
10 |
|
|
#undef mempcpy
|
11 |
|
|
#define mempcpy(dst, src, len) \
|
12 |
|
|
__builtin___mempcpy_chk (dst, src, len, os (dst))
|
13 |
|
|
#undef memmove
|
14 |
|
|
#define memmove(dst, src, len) \
|
15 |
|
|
__builtin___memmove_chk (dst, src, len, os (dst))
|
16 |
|
|
#undef memset
|
17 |
|
|
#define memset(dst, val, len) \
|
18 |
|
|
__builtin___memset_chk (dst, val, len, os (dst))
|
19 |
|
|
#undef strcpy
|
20 |
|
|
#define strcpy(dst, src) \
|
21 |
|
|
__builtin___strcpy_chk (dst, src, os (dst))
|
22 |
|
|
#undef stpcpy
|
23 |
|
|
#define stpcpy(dst, src) \
|
24 |
|
|
__builtin___stpcpy_chk (dst, src, os (dst))
|
25 |
|
|
#undef strcat
|
26 |
|
|
#define strcat(dst, src) \
|
27 |
|
|
__builtin___strcat_chk (dst, src, os (dst))
|
28 |
|
|
#undef strncpy
|
29 |
|
|
#define strncpy(dst, src, len) \
|
30 |
|
|
__builtin___strncpy_chk (dst, src, len, os (dst))
|
31 |
|
|
#undef strncat
|
32 |
|
|
#define strncat(dst, src, len) \
|
33 |
|
|
__builtin___strncat_chk (dst, src, len, os (dst))
|
34 |
|
|
#undef sprintf
|
35 |
|
|
#define sprintf(dst, ...) \
|
36 |
|
|
__builtin___sprintf_chk (dst, 0, os (dst), __VA_ARGS__)
|
37 |
|
|
#undef vsprintf
|
38 |
|
|
#define vsprintf(dst, fmt, ap) \
|
39 |
|
|
__builtin___vsprintf_chk (dst, 0, os (dst), fmt, ap)
|
40 |
|
|
#undef snprintf
|
41 |
|
|
#define snprintf(dst, len, ...) \
|
42 |
|
|
__builtin___snprintf_chk (dst, len, 0, os (dst), __VA_ARGS__)
|
43 |
|
|
#undef vsnprintf
|
44 |
|
|
#define vsnprintf(dst, len, fmt, ap) \
|
45 |
|
|
__builtin___vsnprintf_chk (dst, len, 0, os (dst), fmt, ap)
|
46 |
|
|
|
47 |
|
|
/* Now "redefine" even builtins for the purpose of testing. */
|
48 |
|
|
#undef __builtin_memcpy
|
49 |
|
|
#define __builtin_memcpy(dst, src, len) memcpy (dst, src, len)
|
50 |
|
|
#undef __builtin_mempcpy
|
51 |
|
|
#define __builtin_mempcpy(dst, src, len) mempcpy (dst, src, len)
|
52 |
|
|
#undef __builtin_memmove
|
53 |
|
|
#define __builtin_memmove(dst, src, len) memmove (dst, src, len)
|
54 |
|
|
#undef __builtin_memset
|
55 |
|
|
#define __builtin_memset(dst, val, len) memset (dst, val, len)
|
56 |
|
|
#undef __builtin_strcpy
|
57 |
|
|
#define __builtin_strcpy(dst, src) strcpy (dst, src)
|
58 |
|
|
#undef __builtin_stpcpy
|
59 |
|
|
#define __builtin_stpcpy(dst, src) stpcpy (dst, src)
|
60 |
|
|
#undef __builtin_strcat
|
61 |
|
|
#define __builtin_strcat(dst, src) strcat (dst, src)
|
62 |
|
|
#undef __builtin_strncpy
|
63 |
|
|
#define __builtin_strncpy(dst, src, len) strncpy (dst, src, len)
|
64 |
|
|
#undef __builtin_strncat
|
65 |
|
|
#define __builtin_strncat(dst, src, len) strncat (dst, src, len)
|
66 |
|
|
#undef __builtin_sprintf
|
67 |
|
|
#define __builtin_sprintf(dst, ...) sprintf (dst, __VA_ARGS__)
|
68 |
|
|
#undef __builtin_vsprintf
|
69 |
|
|
#define __builtin_vsprintf(dst, fmt, ap) vsprintf (dst, fmt, ap)
|
70 |
|
|
#undef __builtin_snprintf
|
71 |
|
|
#define __builtin_snprintf(dst, len, ...) snprintf (dst, len, __VA_ARGS__)
|
72 |
|
|
#undef __builtin_vsnprintf
|
73 |
|
|
#define __builtin_vsnprintf(dst, len, fmt, ap) vsnprintf (dst, len, fmt, ap)
|
74 |
|
|
|
75 |
|
|
extern void *chk_fail_buf[];
|
76 |
|
|
extern volatile int chk_fail_allowed, chk_calls;
|
77 |
|
|
extern volatile int memcpy_disallowed, mempcpy_disallowed, memmove_disallowed;
|
78 |
|
|
extern volatile int memset_disallowed, strcpy_disallowed, stpcpy_disallowed;
|
79 |
|
|
extern volatile int strncpy_disallowed, strcat_disallowed, strncat_disallowed;
|
80 |
|
|
extern volatile int sprintf_disallowed, vsprintf_disallowed;
|
81 |
|
|
extern volatile int snprintf_disallowed, vsnprintf_disallowed;
|