From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by dpdk.org (Postfix) with ESMTP id 3127F1B350; Tue, 3 Oct 2017 13:52:32 +0200 (CEST) Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga101.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Oct 2017 04:52:30 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.42,474,1500966000"; d="scan'208";a="1201632830" Received: from gklab-246-072.igk.intel.com (HELO Sent) ([10.217.246.72]) by fmsmga001.fm.intel.com with SMTP; 03 Oct 2017 04:52:28 -0700 Received: by Sent (sSMTP sendmail emulation); Tue, 03 Oct 2017 13:48:04 +0200 From: Kuba Kozak To: konstantin.ananyev@intel.com Cc: dev@dpdk.org, Kuba Kozak , stable@dpdk.org Date: Tue, 3 Oct 2017 13:48:02 +0200 Message-Id: <1507031282-12469-1-git-send-email-kubax.kozak@intel.com> X-Mailer: git-send-email 2.7.4 Subject: [dpdk-stable] [PATCH] l3fwd-acl: fix unchecked return value X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 03 Oct 2017 11:52:32 -0000 Add return value check and error handling for fseek call. Coverity issue: 143435 Fixes: 361b2e9559fc ("acl: new sample l3fwd-acl") Cc: konstantin.ananyev@intel.com Cc: stable@dpdk.org Signed-off-by: Kuba Kozak Acked-by: Konstantin Ananyev --- examples/l3fwd-acl/main.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/examples/l3fwd-acl/main.c b/examples/l3fwd-acl/main.c index 8eff4de..708e9eb 100644 --- a/examples/l3fwd-acl/main.c +++ b/examples/l3fwd-acl/main.c @@ -1026,6 +1026,7 @@ add_rules(const char *rule_path, char buff[LINE_MAX]; FILE *fh = fopen(rule_path, "rb"); unsigned int i = 0; + int val; if (fh == NULL) rte_exit(EXIT_FAILURE, "%s: Open %s failed\n", __func__, @@ -1042,7 +1043,11 @@ add_rules(const char *rule_path, rte_exit(EXIT_FAILURE, "Not find any route entries in %s!\n", rule_path); - fseek(fh, 0, SEEK_SET); + val = fseek(fh, 0, SEEK_SET); + if (val < 0) { + rte_exit(EXIT_FAILURE, "%s: File seek operation failed\n", + __func__); + } acl_rules = calloc(acl_num, rule_size); -- 2.7.4