netem/maketable: Check return value of fstat()

Otherwise info.st_size may contain garbage.

Signed-off-by: Phil Sutter <phil@nwl.cc>
This commit is contained in:
Phil Sutter 2017-08-21 11:27:03 +02:00 committed by Stephen Hemminger
parent 301826beb3
commit d304b05c12
1 changed files with 2 additions and 2 deletions

View File

@ -24,8 +24,8 @@ readdoubles(FILE *fp, int *number)
int limit;
int n=0, i;
fstat(fileno(fp), &info);
if (info.st_size > 0) {
if (!fstat(fileno(fp), &info) &&
info.st_size > 0) {
limit = 2*info.st_size/sizeof(double); /* @@ approximate */
} else {
limit = 10000;