From eecef18261cc278fbc13ecbfb4e5bc10762cc794 Mon Sep 17 00:00:00 2001 From: sin Date: Tue, 24 Feb 2015 18:12:27 +0000 Subject: Remove compile time checks These can produce false positives. Given that we support fortify source level 1 we shouldn't break valid code. --- include/stdio.h | 15 --------------- 1 file changed, 15 deletions(-) (limited to 'include/stdio.h') diff --git a/include/stdio.h b/include/stdio.h index a637f83..aeff658 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -5,24 +5,17 @@ #if defined(_FORTIFY_SOURCE) && _FORTIFY_SOURCE > 0 && defined(__OPTIMIZE__) && __OPTIMIZE__ > 0 -#define __errordecl(name, msg) extern void name(void) __attribute__ ((__error__(msg))) - -__errordecl(__fgets_error, "fgets: buffer overflow detected"); static inline __attribute__ ((always_inline)) char * __fortify_fgets(char *s, int n, FILE *fp) { size_t bos = __builtin_object_size(s, 0); - if (__builtin_constant_p(n) && (size_t)n > bos) - __fgets_error(); - if ((size_t)n > bos) __builtin_trap(); return fgets(s, n, fp); } -__errordecl(__vsnprintf_error, "vsnprintf: buffer overflow detected"); static inline __attribute__ ((always_inline)) __attribute__ ((__format__ (printf, 3, 0))) @@ -32,9 +25,6 @@ __fortify_vsnprintf(char *s, size_t n, const char *fmt, __builtin_va_list ap) { size_t bos = __builtin_object_size(s, 0); - if (__builtin_constant_p(n) && n > bos) - __vsnprintf_error(); - if (n > bos) __builtin_trap(); return vsnprintf(s, n, fmt, ap); @@ -45,20 +35,15 @@ __fortify_vsnprintf(char *s, size_t n, const char *fmt, __builtin_va_list ap) #undef vsnprintf #define vsnprintf(s, n, fmt, ap) __fortify_vsnprintf(s, n, fmt, ap) -__errordecl(__snprintf_error, "snprintf: buffer overflow detected"); #undef snprintf #define snprintf(s, n, fmt, ...) ({ \ size_t _n = (n); \ size_t bos = __builtin_object_size(s, 0); \ - if (__builtin_constant_p(_n) && _n > bos) \ - __snprintf_error(); \ if (_n > bos) \ __builtin_trap(); \ snprintf(s, _n, fmt, ## __VA_ARGS__); \ }) -#undef __errordecl - #endif #endif -- cgit v1.3