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 E030FA04E6; Tue, 10 Nov 2020 09:24:02 +0100 (CET) Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 1F9B62AB; Tue, 10 Nov 2020 09:24:00 +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 CD98A23D for ; Tue, 10 Nov 2020 09:23:57 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1604996636; 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: in-reply-to:in-reply-to:references:references; bh=2wcEVOBQ2AmRgNk9mJ2RAYzy63OBkqoL//rHB/orcIM=; b=W/fHf0GI+ZYqr5yNnT97dkedvWUDEgvQivwCIVOY5xnvxzgMU7DWVLgyLihQQzFaj/XeyO w3wZMicVrwfrpMzDB5LpzMzotOrfUU92Y6wz2nldCBdn/G6thzl4rVel6n+07m1N7qIxNo wqR7mElkb3Ea7XZlcbvQtDn3DIOHvZQ= Received: from mail-vs1-f71.google.com (mail-vs1-f71.google.com [209.85.217.71]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-112--Sikf4qiN6-GclSu5eVnNg-1; Tue, 10 Nov 2020 03:23:54 -0500 X-MC-Unique: -Sikf4qiN6-GclSu5eVnNg-1 Received: by mail-vs1-f71.google.com with SMTP id f23so4199315vsh.7 for ; Tue, 10 Nov 2020 00:23:54 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=2wcEVOBQ2AmRgNk9mJ2RAYzy63OBkqoL//rHB/orcIM=; b=FPSihEGMMbBNbO5GbGeUHliAWcMSUrZWK0b1/G7JZNF+ptPlzd6AOm/eOBpYXsSrJv TA+/YE4H6ZMEi3SWgEcdFLtgr6Z4wwwU20C7XNvuVPdBt8czeWZOEj0LiAoM4vdnK4Q1 OrRvTdaqkyoFcblv7H2+wZW3bzcTZSgqeAh4YUmWNMDDYf8Iq5vVLN49mg6TLfGsdlFu kTKj8gs9FSBLbaSFlRs1CFGvgiwsX3RhLexs2cx4WKenTB8OzE37gZzlTTaoogWS5gW5 NnYRBNZBnEby6GmORSGLIStCbSQ6uD38ODIDGYyFhvFYMt5WNJRhLUNrAtEsrLcGe29Q YtfA== X-Gm-Message-State: AOAM531BqdsC1u0JWtEn0nrJAP0Z+pcYK4BfgrsvyuR9iutrHPoT2n4H EE3DDg8MGRsTr1XCfWie9hJ3wTwcaB3lvJF01DlC2nSMUgNrOWyau/xCL9mD0mcc/pSOFC73ntf loKp/cErFLJeGnWdDlUY= X-Received: by 2002:a05:6102:2362:: with SMTP id o2mr5302473vsa.5.1604996634151; Tue, 10 Nov 2020 00:23:54 -0800 (PST) X-Google-Smtp-Source: ABdhPJx9R/8gnGVbMrsOdCl1vU0DAiCGdpUMptDfHtHPGTzi9QpSTHpoldzjV59vVFWUKvU/3Fn2nJykbc839Oj8QDM= X-Received: by 2002:a05:6102:2362:: with SMTP id o2mr5302463vsa.5.1604996633954; Tue, 10 Nov 2020 00:23:53 -0800 (PST) MIME-Version: 1.0 References: <20201029125339.30916-1-ibtisam.tariq@emumba.com> In-Reply-To: From: David Marchand Date: Tue, 10 Nov 2020 09:23:42 +0100 Message-ID: To: Ibtisam Tariq Cc: "Kovacevic, Marko" , "Ananyev, Konstantin" , "Pattan, Reshma" , "Mcnamara, John" , Cristian Dumitrescu , "Singh, Jasvinder" , "Xia, Chenbo" , Maxime Coquelin , Xiaoyun Li , dev Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=dmarchan@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset="UTF-8" Subject: Re: [dpdk-dev] [PATCH 1/8] examples/fips_validation: enhance getopt_long usage 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 Tue, Nov 10, 2020 at 7:10 AM Ibtisam Tariq wrote: > IMHO, it cannot be moved to read_uint16 parser. > If we do, we can't verify that the user input value is greater than > UINT16 MAX or not on the overflow data. > > > + if (data_room_size == 0 || > > > + data_room_size > UINT16_MAX) { > > > + cryptodev_fips_validate_usage(prgname); > > > + return -EINVAL; > > > + } > > The temp variable:data_room_size is necessary to check the overflow of > the command line argument. The overflow check can go to a new read_uint16 parser, like what is done in other parsers in this example. int parser_read_uint32(uint32_t *value, char *p) { uint64_t val = 0; int ret = parser_read_uint64(&val, p); if (ret < 0) return ret; if (val > UINT32_MAX) return -EINVAL; *value = val; return 0; } The parser_read_uint16 caller can do any additional check, here test for 0 value. -- David Marchand