blob: 44e76bd90af76938f04f7e7b0df8818d4bb81e61 [file] [log] [blame]
Jeff Kingc8af66a2018-07-26 03:21:05 -04001#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)
Jeff King1b11b642018-07-24 05:26:39 -040015#undef strcat
16#define strcat(x,y) BANNED(strcat)
Jeff Kinge488b7a2018-07-24 05:28:28 -040017#undef strncpy
18#define strncpy(x,y,n) BANNED(strncpy)
Eric Wongace57072019-01-02 09:38:46 +000019#undef strncat
20#define strncat(x,y,n) BANNED(strncat)
Taylor Blau60ff56f2023-04-24 18:20:26 -040021#undef strtok
22#define strtok(x,y) BANNED(strtok)
23#undef strtok_r
24#define strtok_r(x,y,z) BANNED(strtok_r)
Jeff Kingc8af66a2018-07-26 03:21:05 -040025
Jeff Kingcc8fdae2018-07-24 05:27:19 -040026#undef sprintf
27#undef vsprintf
Jeff Kingcc8fdae2018-07-24 05:27:19 -040028#define sprintf(...) BANNED(sprintf)
29#define vsprintf(...) BANNED(vsprintf)
Jeff Kingcc8fdae2018-07-24 05:27:19 -040030
Jeff King1fbfdf52020-12-01 13:11:37 -080031#undef gmtime
32#define gmtime(t) BANNED(gmtime)
33#undef localtime
34#define localtime(t) BANNED(localtime)
35#undef ctime
36#define ctime(t) BANNED(ctime)
Jeff King91aef032020-12-01 13:11:38 -080037#undef ctime_r
38#define ctime_r(t, buf) BANNED(ctime_r)
Jeff King1fbfdf52020-12-01 13:11:37 -080039#undef asctime
40#define asctime(t) BANNED(asctime)
Jeff King91aef032020-12-01 13:11:38 -080041#undef asctime_r
42#define asctime_r(t, buf) BANNED(asctime_r)
Jeff King1fbfdf52020-12-01 13:11:37 -080043
Jeff Kingc8af66a2018-07-26 03:21:05 -040044#endif /* BANNED_H */