add checks after reading data
This commit is contained in:
@ -142,8 +142,7 @@ void ReaderNative::skip()
|
|||||||
read_lines(2);
|
read_lines(2);
|
||||||
bigint natoms;
|
bigint natoms;
|
||||||
int rv = sscanf(line,BIGINT_FORMAT,&natoms);
|
int rv = sscanf(line,BIGINT_FORMAT,&natoms);
|
||||||
if (rv != 1)
|
if (rv != 1) error->one(FLERR,"Dump file is incorrectly formatted");
|
||||||
error->one(FLERR,"Dump file is incorrectly formatted");
|
|
||||||
|
|
||||||
read_lines(5);
|
read_lines(5);
|
||||||
|
|
||||||
@ -164,20 +163,17 @@ void ReaderNative::skip_reading_magic_str()
|
|||||||
if (is_known_magic_str() && revision > 0x0001) {
|
if (is_known_magic_str() && revision > 0x0001) {
|
||||||
int len;
|
int len;
|
||||||
read_buf(&len, sizeof(int), 1);
|
read_buf(&len, sizeof(int), 1);
|
||||||
|
if (len < 0) error->one(FLERR,"Dump file is invalid or corrupted");
|
||||||
|
|
||||||
if (len > 0) {
|
|
||||||
// has units
|
// has units
|
||||||
skip_buf(sizeof(char)*len);
|
if (len > 0) skip_buf(sizeof(char)*len);
|
||||||
}
|
|
||||||
|
|
||||||
char flag = 0;
|
char flag = 0;
|
||||||
read_buf(&flag, sizeof(char), 1);
|
read_buf(&flag, sizeof(char), 1);
|
||||||
|
if (flag) skip_buf(sizeof(double));
|
||||||
if (flag) {
|
|
||||||
skip_buf(sizeof(double));
|
|
||||||
}
|
|
||||||
|
|
||||||
read_buf(&len, sizeof(int), 1);
|
read_buf(&len, sizeof(int), 1);
|
||||||
|
if (len < 0) error->one(FLERR,"Dump file is invalid or corrupted");
|
||||||
skip_buf(sizeof(char)*len);
|
skip_buf(sizeof(char)*len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user