snprintf instead of sprintf

This commit is contained in:
Simon Long 2024-01-05 12:15:03 +00:00
parent 634c80490a
commit e94d5035f0

View file

@ -1492,10 +1492,10 @@ rcxml_read(const char *filename)
line = NULL; line = NULL;
len = 0; len = 0;
if (filename) { if (filename) {
sprintf(rcxml, "%s", filename); snprintf(rcxml, sizeof(rcxml), "%s", filename);
i = 0; i = 0;
} else { } else {
sprintf(rcxml, "%s/rc.xml", config_dir_n(i)); snprintf(rcxml, sizeof(rcxml), "%s/rc.xml", config_dir_n(i));
} }
/* Reading file into buffer before parsing - better for unit tests */ /* Reading file into buffer before parsing - better for unit tests */
stream = fopen(rcxml, "r"); stream = fopen(rcxml, "r");