use snprintf() instead of sprintf() to avoid buffer overflows when copying style names

This commit is contained in:
Axel Kohlmeyer
2019-06-21 21:23:20 -04:00
parent 7a56a4be24
commit f190647ab4
5 changed files with 26 additions and 26 deletions

View File

@ -1818,11 +1818,11 @@ void Input::pair_style()
if (!match && lmp->suffix_enable) {
char estyle[256];
if (lmp->suffix) {
sprintf(estyle,"%s/%s",arg[0],lmp->suffix);
snprintf(estyle,256,"%s/%s",arg[0],lmp->suffix);
if (strcmp(estyle,force->pair_style) == 0) match = 1;
}
if (lmp->suffix2) {
sprintf(estyle,"%s/%s",arg[0],lmp->suffix2);
snprintf(estyle,256,"%s/%s",arg[0],lmp->suffix2);
if (strcmp(estyle,force->pair_style) == 0) match = 1;
}
}