]>
Commit | Line | Data |
---|---|---|
c8af66ab JK |
1 | #ifndef BANNED_H |
2 | #define BANNED_H | |
3 | ||
4 | /* | |
5 | * This header lists functions that have been banned from our code base, | |
6 | * because they're too easy to misuse (and even if used correctly, | |
7 | * complicate audits). Including this header turns them into compile-time | |
8 | * errors. | |
9 | */ | |
10 | ||
11 | #define BANNED(func) sorry_##func##_is_a_banned_function | |
12 | ||
13 | #undef strcpy | |
14 | #define strcpy(x,y) BANNED(strcpy) | |
1b11b64b JK |
15 | #undef strcat |
16 | #define strcat(x,y) BANNED(strcat) | |
e488b7ab JK |
17 | #undef strncpy |
18 | #define strncpy(x,y,n) BANNED(strncpy) | |
ace5707a EW |
19 | #undef strncat |
20 | #define strncat(x,y,n) BANNED(strncat) | |
c8af66ab | 21 | |
cc8fdaee JK |
22 | #undef sprintf |
23 | #undef vsprintf | |
24 | #ifdef HAVE_VARIADIC_MACROS | |
25 | #define sprintf(...) BANNED(sprintf) | |
26 | #define vsprintf(...) BANNED(vsprintf) | |
27 | #else | |
28 | #define sprintf(buf,fmt,arg) BANNED(sprintf) | |
60d198d0 | 29 | #define vsprintf(buf,fmt,arg) BANNED(vsprintf) |
cc8fdaee JK |
30 | #endif |
31 | ||
1fbfdf55 JK |
32 | #undef gmtime |
33 | #define gmtime(t) BANNED(gmtime) | |
34 | #undef localtime | |
35 | #define localtime(t) BANNED(localtime) | |
36 | #undef ctime | |
37 | #define ctime(t) BANNED(ctime) | |
91aef030 JK |
38 | #undef ctime_r |
39 | #define ctime_r(t, buf) BANNED(ctime_r) | |
1fbfdf55 JK |
40 | #undef asctime |
41 | #define asctime(t) BANNED(asctime) | |
91aef030 JK |
42 | #undef asctime_r |
43 | #define asctime_r(t, buf) BANNED(asctime_r) | |
1fbfdf55 | 44 | |
c8af66ab | 45 | #endif /* BANNED_H */ |