Skip to content
Snippets Groups Projects
Commit 26bc17de authored by Rob Swindell's avatar Rob Swindell :speech_balloon:
Browse files

Add run-time check for non-terminating/unsafe snprintf() function

Only in debug builds.
If this check fails, then we may be producing/using potentially un-terminated strings and need to do something about that. By default, xpdev/genwrap.h redefines snprintf() as safe_snprintf(), so this check *should* always succeed.
parent 2d033355
No related branches found
No related tags found
1 merge request!463MRC mods by Codefenix (2024-10-20)
Pipeline #2594 passed
......@@ -4902,6 +4902,14 @@ void bbs_thread(void* arg)
#ifdef _DEBUG
lprintf(LOG_DEBUG, "sizeof: int=%d, long=%d, off_t=%d, time_t=%d"
,(int)sizeof(int), (int)sizeof(long), (int)sizeof(off_t), (int)sizeof(time_t));
memset(str, 0xff, sizeof(str));
snprintf(str, 2, "\x01\x02");
if(str[1] != '\0') {
lprintf(LOG_CRIT, "Non-terminating (unsafe) snprintf function detected (0x%02X instead of 0x00)", (uchar)str[1]);
cleanup(1);
return;
}
#endif
if(startup->first_node<1 || startup->first_node>startup->last_node) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment