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

@ -706,7 +706,7 @@ void ReadData::command(int narg, char **arg)
} else {
char str[128];
sprintf(str,"Unknown identifier in data file: %s",keyword);
snprintf(str,128,"Unknown identifier in data file: %s",keyword);
error->all(FLERR,str);
}
@ -1919,7 +1919,7 @@ void ReadData::open(char *file)
else {
#ifdef LAMMPS_GZIP
char gunzip[128];
sprintf(gunzip,"gzip -c -d %s",file);
snprintf(gunzip,128,"gzip -c -d %s",file);
#ifdef _WIN32
fp = _popen(gunzip,"rb");
@ -1934,7 +1934,7 @@ void ReadData::open(char *file)
if (fp == NULL) {
char str[128];
sprintf(str,"Cannot open file %s",file);
snprintf(str,128,"Cannot open file %s",file);
error->one(FLERR,str);
}
}