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

@ -41,7 +41,7 @@ void Reader::open_file(const char *file)
else {
#ifdef LAMMPS_GZIP
char gunzip[1024];
sprintf(gunzip,"gzip -c -d %s",file);
snprintf(gunzip,1024,"gzip -c -d %s",file);
#ifdef _WIN32
fp = _popen(gunzip,"rb");
@ -56,7 +56,7 @@ void Reader::open_file(const 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);
}
}