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

@ -269,7 +269,7 @@ void WriteRestart::write(char *file)
fp = fopen(hfile,"wb");
if (fp == NULL) {
char str[128];
sprintf(str,"Cannot open restart file %s",hfile);
snprintf(str,128,"Cannot open restart file %s",hfile);
error->one(FLERR,str);
}
if (multiproc) delete [] hfile;
@ -334,7 +334,7 @@ void WriteRestart::write(char *file)
fp = fopen(multiname,"wb");
if (fp == NULL) {
char str[128];
sprintf(str,"Cannot open restart file %s",multiname);
snprintf(str,128,"Cannot open restart file %s",multiname);
error->one(FLERR,str);
}
write_int(PROCSPERFILE,nclusterprocs);