From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from dpdk.org (dpdk.org [92.243.14.124]) by inbox.dpdk.org (Postfix) with ESMTP id 7AFF8A034F; Tue, 12 May 2020 17:31:22 +0200 (CEST) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 0CB651BFE6; Tue, 12 May 2020 17:31:06 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id BF7C21BF98 for ; Tue, 12 May 2020 17:31:02 +0200 (CEST) IronPort-SDR: VMebB5CNhYsFWjU3FYVlSj8buoaZ701Ul73iW2Fuc4Zn+i0l4WrCGKTioYuBYk53HWQ9rmjOj5 3BJFkyzCK6OQ== X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 12 May 2020 08:31:02 -0700 IronPort-SDR: Tj5Nw04ORgJtlJWBB3ksZ6q5o80YwAGeni6tXRh7Ly2zQDvXuAHgN91AAAI1xFtyUB3HbEbtHz Sn2cMahfhlRg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.73,384,1583222400"; d="scan'208";a="409336943" Received: from silpixa00399953.ir.intel.com (HELO silpixa00399953.ger.corp.intel.com) ([10.237.222.53]) by orsmga004.jf.intel.com with ESMTP; 12 May 2020 08:31:01 -0700 From: Ciara Power To: bruce.richardson@intel.com Cc: dev@dpdk.org, Ciara Power Date: Tue, 12 May 2020 16:28:59 +0100 Message-Id: <20200512152902.70211-3-ciara.power@intel.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200512152902.70211-1-ciara.power@intel.com> References: <20200512152902.70211-1-ciara.power@intel.com> Subject: [dpdk-dev] [PATCH 2/5] telemetry: fix error checking for strchr function X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" The strchr function return was not being checked which could lead to NULL deferencing later in the function. Coverity issue: 358438 Coverity issue: 358445 Fixes: b80fe1805eee ("telemetry: introduce backward compatibility") Cc: ciara.power@intel.com Signed-off-by: Ciara Power --- lib/librte_telemetry/telemetry_legacy.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/lib/librte_telemetry/telemetry_legacy.c b/lib/librte_telemetry/telemetry_legacy.c index 8e24eb4cb9..10b575adfd 100644 --- a/lib/librte_telemetry/telemetry_legacy.c +++ b/lib/librte_telemetry/telemetry_legacy.c @@ -82,8 +82,16 @@ register_client(const char *cmd __rte_unused, const char *params, int fd; struct sockaddr_un addrs; + if (!strchr(params, ':')) { + fprintf(stderr, "Invalid data\n"); + return -1; + } strlcpy(data, strchr(params, ':'), sizeof(data)); memcpy(data, &data[strlen(":\"")], strlen(data)); + if (!strchr(data, '\"')) { + fprintf(stderr, "Invalid client data\n"); + return -1; + } *strchr(data, '\"') = 0; fd = socket(AF_UNIX, SOCK_SEQPACKET, 0); @@ -178,6 +186,8 @@ parse_client_request(char *buffer, int buf_len, int s) if (!strchr(data_ptr, '{')) data_sep = data_ptr[strlen(callbacks[i].data)]; else { + if (!strchr(data_ptr, '}')) + return -EINVAL; char *data_end = strchr(data_ptr, '}'); data = data_ptr + strlen(DATA_REQ_LABEL); data_sep = data_end[1]; -- 2.17.1