BUILD: bug.h: add a warning in the base API when unsafe functions are used
authorWilly Tarreau <w@1wt.eu>
Fri, 7 Apr 2023 12:57:13 +0000 (14:57 +0200)
committerWilly Tarreau <w@1wt.eu>
Fri, 7 Apr 2023 16:21:36 +0000 (18:21 +0200)
commit7f2b3f9431f279d71a59dc73b77139d2ce16e503
tree0a8fa428c034fec5497442871a108bec4ba4b214
parentd4991271486975b245e4607d535b2e4b662981fc
BUILD: bug.h: add a warning in the base API when unsafe functions are used

Once in a while we introduce an sprintf() or strncat() function by
accident. These ones are particularly dangerous and must never ever
be used because the only way to use them safely is at least as
complicated if not more, than their safe counterparts. By redefining
a few of these functions with an attribute_warning() we can deliver a
message to the developer who is tempted to use them. This commit does
it for strcat(), strcpy(), strncat(), sprintf(), vsprintf(). More could
come later if needed, such as strtok() and maybe a few others, but these
are less common.
include/haproxy/bug.h