X-Git-Url: https://vcs.fsf.org/?a=blobdiff_plain;f=src%2Fsrc%2Fmytypes.h;h=eba3f7e9de8993c2f01d65dc27f7abe1e5c7b9d2;hb=9214d2e4dfd9d4f29e9cb7a0eea8a0758ed1b34a;hp=de2371c7d9200c296c90f1001ed22234f29eaa87;hpb=aaabfafe3fb76b1e09a68317ef4b3d5bc94fa9be;p=exim.git diff --git a/src/src/mytypes.h b/src/src/mytypes.h index de2371c7d..eba3f7e9d 100644 --- a/src/src/mytypes.h +++ b/src/src/mytypes.h @@ -77,6 +77,7 @@ almost always literal strings. */ #define CUS (const unsigned char *) #define USS (unsigned char **) #define CUSS (const unsigned char **) +#define CCSS (const char **) /* The C library string functions expect "char *" arguments. Use macros to avoid having to write a cast each time. We do this for string and file @@ -100,19 +101,19 @@ functions that are called quite often; for other calls to external libraries #define Uread(f,b,l) read(f,CS(b),l) #define Urename(s,t) rename(CCS(s),CCS(t)) #define Ustat(s,t) stat(CCS(s),t) -#define Ustrcat(s,t) __Ustrcat(s,t, __FUNCTION__, __LINE__) +#define Ustrcat(s,t) __Ustrcat(s, CUS(t), __FUNCTION__, __LINE__) #define Ustrchr(s,n) US strchr(CCS(s),n) #define CUstrchr(s,n) CUS strchr(CCS(s),n) #define CUstrerror(n) CUS strerror(n) #define Ustrcmp(s,t) strcmp(CCS(s),CCS(t)) -#define Ustrcpy(s,t) __Ustrcpy(s,t, __FUNCTION__, __LINE__) +#define Ustrcpy(s,t) __Ustrcpy(s, CUS(t), __FUNCTION__, __LINE__) #define Ustrcpy_nt(s,t) strcpy(CS s, CCS t) /* no taint check */ #define Ustrcspn(s,t) strcspn(CCS(s),CCS(t)) #define Ustrftime(s,m,f,t) strftime(CS(s),m,f,t) #define Ustrlen(s) (int)strlen(CCS(s)) -#define Ustrncat(s,t,n) __Ustrncat(s,t,n, __FUNCTION__, __LINE__) +#define Ustrncat(s,t,n) __Ustrncat(s, CUS(t),n, __FUNCTION__, __LINE__) #define Ustrncmp(s,t,n) strncmp(CCS(s),CCS(t),n) -#define Ustrncpy(s,t,n) __Ustrncpy(s,t,n, __FUNCTION__, __LINE__) +#define Ustrncpy(s,t,n) __Ustrncpy(s, CUS(t),n, __FUNCTION__, __LINE__) #define Ustrncpy_nt(s,t,n) strncpy(CS s, CCS t, n) /* no taint check */ #define Ustrpbrk(s,t) strpbrk(CCS(s),CCS(t)) #define Ustrrchr(s,n) US strrchr(CCS(s),n) @@ -134,8 +135,13 @@ By extension, a variable pointing to this address is tainted. static inline BOOL is_tainted(const void * p) { -#ifdef MACRO_PREDEF +#if defined(COMPILE_UTILITY) || defined(MACRO_PREDEF) return FALSE; + +#elif !defined(TAINT_CHECK_FAST) +extern BOOL is_tainted_fn(const void *); +return is_tainted_fn(p); + #else extern void * tainted_base, * tainted_top; return p >= tainted_base && p < tainted_top; @@ -144,28 +150,28 @@ return p >= tainted_base && p < tainted_top; static inline uschar * __Ustrcat(uschar * dst, const uschar * src, const char * func, int line) { -#ifndef COMPILE_UTILITY +#if !defined(COMPILE_UTILITY) && !defined(MACRO_PREDEF) if (!is_tainted(dst) && is_tainted(src)) die_tainted(US"Ustrcat", CUS func, line); #endif return US strcat(CS dst, CCS src); } static inline uschar * __Ustrcpy(uschar * dst, const uschar * src, const char * func, int line) { -#ifndef COMPILE_UTILITY +#if !defined(COMPILE_UTILITY) && !defined(MACRO_PREDEF) if (!is_tainted(dst) && is_tainted(src)) die_tainted(US"Ustrcpy", CUS func, line); #endif return US strcpy(CS dst, CCS src); } static inline uschar * __Ustrncat(uschar * dst, const uschar * src, size_t n, const char * func, int line) { -#ifndef COMPILE_UTILITY +#if !defined(COMPILE_UTILITY) && !defined(MACRO_PREDEF) if (!is_tainted(dst) && is_tainted(src)) die_tainted(US"Ustrncat", CUS func, line); #endif return US strncat(CS dst, CCS src, n); } static inline uschar * __Ustrncpy(uschar * dst, const uschar * src, size_t n, const char * func, int line) { -#ifndef COMPILE_UTILITY +#if !defined(COMPILE_UTILITY) && !defined(MACRO_PREDEF) if (!is_tainted(dst) && is_tainted(src)) die_tainted(US"Ustrncpy", CUS func, line); #endif return US strncpy(CS dst, CCS src, n);