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 1C6CCA0526; Tue, 10 Nov 2020 10:34:47 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 6C5C6F64; Tue, 10 Nov 2020 10:34:45 +0100 (CET) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by dpdk.org (Postfix) with ESMTP id 169E12AB for ; Tue, 10 Nov 2020 10:34:41 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1605000880; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=WfmH27IFoiy8BViMAHY+uBoSO0yWrWbFwms6jwlIMXI=; b=F5Ij7rJ0MdwYtdjVAPuNfV8v7tygUQJRuXHG36ADy8wmF39inyLQSin6PbsIigtyJKp2XD HQPzogFAYZ9BmrFIMDnOGAXqfVRr7EuhMoWwt3rPtOqh2rJ8uJ+rNCJ7/tCUllUy9TwseP SM/d12hcQaXxrMSillE6b7NrloZwkeY= Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-216-Ykp2t-ADOMKp35_33eNkoQ-1; Tue, 10 Nov 2020 04:34:36 -0500 X-MC-Unique: Ykp2t-ADOMKp35_33eNkoQ-1 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 371701006C9D; Tue, 10 Nov 2020 09:34:34 +0000 (UTC) Received: from [10.36.110.32] (unknown [10.36.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E103A10013DB; Tue, 10 Nov 2020 09:34:32 +0000 (UTC) To: Cheng Jiang , chenbo.xia@intel.com Cc: dev@dpdk.org, patrick.fu@intel.com, YvonneX.Yang@intel.com References: <20201106032343.9099-1-Cheng1.jiang@intel.com> From: Maxime Coquelin Message-ID: Date: Tue, 10 Nov 2020 10:34:31 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.3.1 MIME-Version: 1.0 In-Reply-To: <20201106032343.9099-1-Cheng1.jiang@intel.com> X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=maxime.coquelin@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit Subject: Re: [dpdk-dev] [PATCH v1] examples/vhost: fix string split error handling issue 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" On 11/6/20 4:23 AM, Cheng Jiang wrote: > Add checking return value of string split function to fix the > coverity issue. > > Fixes: 3a04ecb21420 ("examples/vhost: add async vhost args parsing") > Coverity issue: 363739 > > Signed-off-by: Cheng Jiang > --- > examples/vhost/ioat.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/examples/vhost/ioat.c b/examples/vhost/ioat.c > index b2c74f6537..04806c02d7 100644 > --- a/examples/vhost/ioat.c > +++ b/examples/vhost/ioat.c > @@ -54,9 +54,14 @@ open_ioat(const char *value) > } > args_nr = rte_strsplit(substr, strlen(substr), > dma_arg, MAX_VHOST_DEVICE, ','); I think you should check args_nr > 0 explicitly, and maybe even args_nr >= 0. And then propagate the error if condition is met. > - do { > + while (i < args_nr) { > char *arg_temp = dma_arg[i]; > - rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@'); > + uint8_t sub_nr; > + sub_nr = rte_strsplit(arg_temp, strlen(arg_temp), ptrs, 2, '@'); > + if (sub_nr != 2) { > + ret = -1; > + goto out; > + } > > start = strstr(ptrs[0], "txd"); > if (start == NULL) { > @@ -105,7 +110,7 @@ open_ioat(const char *value) > > dma_info->nr++; > i++; > - } while (i < args_nr); > + } > out: > free(input); > return ret; >