]> git.ipfire.org Git - thirdparty/iproute2.git/commitdiff
netem/maketable: Check return value of fstat()
authorPhil Sutter <phil@nwl.cc>
Mon, 21 Aug 2017 09:27:03 +0000 (11:27 +0200)
committerStephen Hemminger <stephen@networkplumber.org>
Tue, 22 Aug 2017 00:17:00 +0000 (17:17 -0700)
Otherwise info.st_size may contain garbage.

Signed-off-by: Phil Sutter <phil@nwl.cc>
netem/maketable.c

index 6aff927be70400688ed6142e97388eec0f73369f..ad660e7d457f058bf1a2fbbe23accd549611bfba 100644 (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;