more buffer overflow avoiding through using snprintf()

This commit is contained in:
Axel Kohlmeyer
2018-09-06 09:57:43 -04:00
parent fbc1c1cfdd
commit 4d52cb9245
9 changed files with 26 additions and 26 deletions

View File

@ -204,7 +204,7 @@ void Universe::add_world(char *str)
if (!valid) {
char msg[128];
sprintf(msg,"Invalid partition string '%s'",str);
snprintf(msg,128,"Invalid partition string '%s'",str);
error->universe_all(FLERR,msg);
}
} else nper = nprocs;
@ -269,7 +269,7 @@ char *date2num(const char *version)
year = atoi(version);
}
char *ver = new char[10];
char *ver = new char[64];
sprintf(ver,"%04d%02d%02d", year % 10000, month, day % 100);
return ver;