more buffer overflow avoiding through using snprintf()
This commit is contained in:
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user