more sscanf() return value checking

This commit is contained in:
Axel Kohlmeyer
2019-07-19 12:01:16 -04:00
parent d730ef5b19
commit e72aef2a96
3 changed files with 13 additions and 10 deletions

View File

@ -5162,8 +5162,8 @@ int VarReader::read_peratom()
for (i = 0; i < nchunk; i++) {
next = strchr(buf,'\n');
*next = '\0';
sscanf(buf,TAGINT_FORMAT " %lg",&tag,&value);
if (tag <= 0 || tag > map_tag_max)
int rv = sscanf(buf,TAGINT_FORMAT " %lg",&tag,&value);
if (tag <= 0 || tag > map_tag_max || rv != 2)
error->one(FLERR,"Invalid atom ID in variable file");
if ((m = atom->map(tag)) >= 0) vstore[m] = value;
buf = next + 1;