From mboxrd@z Thu Jan 1 00:00:00 1970 From: Phil Sutter Subject: [iproute PATCH v2 6/7] netem/maketable: Check return value of fstat() Date: Thu, 17 Aug 2017 19:09:30 +0200 Message-ID: <20170817170931.24302-7-phil@nwl.cc> References: <20170817170931.24302-1-phil@nwl.cc> Cc: netdev@vger.kernel.org To: Stephen Hemminger Return-path: Received: from orbyte.nwl.cc ([151.80.46.58]:60509 "EHLO mail.nwl.cc" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753165AbdHQRJt (ORCPT ); Thu, 17 Aug 2017 13:09:49 -0400 In-Reply-To: <20170817170931.24302-1-phil@nwl.cc> Sender: netdev-owner@vger.kernel.org List-ID: Otherwise info.st_size may contain garbage. Signed-off-by: Phil Sutter --- netem/maketable.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/netem/maketable.c b/netem/maketable.c index 6aff927be7040..ad660e7d457f0 100644 --- a/netem/maketable.c +++ b/netem/maketable.c @@ -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; -- 2.13.1