diff --git a/userspace/engine/banned.h b/userspace/engine/banned.h index 41690220..85dd6f34 100644 --- a/userspace/engine/banned.h +++ b/userspace/engine/banned.h @@ -21,14 +21,18 @@ limitations under the License. // function is used. #define BAN(function) using_##function##_is_banned +// BAN_ALTERNATIVE is same as BAN but the message also provides an alternative +// function that the user could use instead of the banned function. +#define BAN_ALTERNATIVE(function, alternative) using_##function##_is_banned__use_##alternative##_instead + #undef strcpy #define strcpy(a, b) BAN(strcpy) #undef vsprintf -#define vsprintf(a, b, c) BAN(vsprintf) +#define vsprintf(a, b, c) BAN_ALTERNATIVE(vsprintf, vsnprintf) #undef sprintf -#define sprintf(a, b, ...) BAN(sprintf) +#define sprintf(a, b, ...) BAN_ALTERNATIVE(sprintf, snprintf) #undef strcat #define strcat(a, b) BAN(strcat) @@ -40,7 +44,7 @@ limitations under the License. #define strncpy(a, b, c) BAN(strncpy) #undef swprintf -#define swprintf(a, b, c, ...) BAN(swprintf) +#define swprintf(a, b, c, ...) BAN_ALTERNATIVE(swprintf, snprintf) #undef vswprintf -#define vswprintf(a, b, c, d) BAN(vswprintf) +#define vswprintf(a, b, c, d) BAN_ALTERNATIVE(vswprintf, vsnprintf)