From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pf0-f182.google.com (mail-pf0-f182.google.com [209.85.192.182]) by dpdk.org (Postfix) with ESMTP id D08672952 for ; Fri, 22 Apr 2016 18:23:09 +0200 (CEST) Received: by mail-pf0-f182.google.com with SMTP id e128so42555311pfe.3 for ; Fri, 22 Apr 2016 09:23:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=networkplumber-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=Sk9CaKrYylrxf3Y0Hh0UosiHWV6+g4Zkllq/nTRXxUg=; b=xuXBzWHUSdwIiKd2rzWRoZi3F6jA5kq9R8xRALYfZ9MX5dayw1OpeK3Sm2GBGXb9mG StDnWpRp5v/t5O4HpYhS7UyPYbHIrxbv+3hs9bKZoRgvYICGCDGvkdMs5ztBfBv2Qrky I5nQhjTu6KunTM0pWYSCP7x5MXTpsE9lDXxMfcb9iuriXE52KoIWg2gZLQ+KeSrUU8pO kp/x3sJCHmXjiPJMIXtYx3AAcn/+uJ7KrwM53pmX7f5BdyAGxSPPfniwTpP90oS39IPy T0Y2a5yydaIfOfRpflpk9G2tJdLECx6zMnqDMb8dGZp4KhKLMze5Bjuip8CtT5YR3+JJ 1zhA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:date:from:to:cc:subject:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=Sk9CaKrYylrxf3Y0Hh0UosiHWV6+g4Zkllq/nTRXxUg=; b=g3ETUr7eFq8ab0g94pvL+Ntl9BD3hxg0uX0ldfhCis5VbmmeSES1a/NrISeONCRA41 oFhyU5qkFNwvg/MYfBvxAwmOFRpDI7B1jqiwCFUigO8fDs74cOixKdcnZXsRKKss5vdj jHBSVx1yg0wgO0ZTWL7CC21C0JhWD3DZSOx6ejJJuu6xnmIlICOS/IAVozxqFj9ajujU bL3IDoXjHyOHe6ZiPwS7nWODdYcFk7bOxOIKpa9Z3JrJJzS6/bsWEhLls4TYdVtpCuU/ 6hdgvkCHeV4oM4aR3EWLXxB75/Avti8hZmF0u0bA8oRjgj40UQZeNPTHuJACEBK4poZx TCPQ== X-Gm-Message-State: AOPr4FXr/xegI+Ox7Uh81xIp6BiwOM1zUisWkxNTCmqZhGijOI6hkPGdO7gYeeHRKGv1JA== X-Received: by 10.98.55.131 with SMTP id e125mr29713425pfa.86.1461342189136; Fri, 22 Apr 2016 09:23:09 -0700 (PDT) Received: from xeon-e3 (static-50-53-72-186.bvtn.or.frontiernet.net. [50.53.72.186]) by smtp.gmail.com with ESMTPSA id nz6sm10613908pab.39.2016.04.22.09.23.08 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 22 Apr 2016 09:23:08 -0700 (PDT) Date: Fri, 22 Apr 2016 09:23:20 -0700 From: Stephen Hemminger To: Michal Kobylinski Cc: cristian.dumitrescu@intel.com, dev@dpdk.org Message-ID: <20160422092320.3796239c@xeon-e3> In-Reply-To: <1461321661-30272-1-git-send-email-michalx.kobylinski@intel.com> References: <1461321661-30272-1-git-send-email-michalx.kobylinski@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Subject: Re: [dpdk-dev] [PATCH] cfgfile: fix integer overflow X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 22 Apr 2016 16:23:10 -0000 On Fri, 22 Apr 2016 12:41:01 +0200 Michal Kobylinski wrote: > Fix issue reported by Coverity. > > Coverity ID 13289: Integer overflowed argument: The argument will be too > small or even negative, likely resulting in unexpected behavior (for > example, under-allocation in a memory allocation function). > In rte_cfgfile_load: An integer overflow occurs, with the overflowed > value used as an argument to a function > > Fixes: eaafbad419bf ("cfgfile: library to interpret config files") > > Signed-off-by: Michal Kobylinski > --- > lib/librte_cfgfile/rte_cfgfile.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/lib/librte_cfgfile/rte_cfgfile.c b/lib/librte_cfgfile/rte_cfgfile.c > index 75625a2..0a5a279 100644 > --- a/lib/librte_cfgfile/rte_cfgfile.c > +++ b/lib/librte_cfgfile/rte_cfgfile.c > @@ -135,7 +135,7 @@ rte_cfgfile_load(const char *filename, int flags) > goto error1; > } > *end = '\0'; > - _strip(&buffer[1], end - &buffer[1]); > + _strip(&buffer[1], (unsigned)(end - &buffer[1])); > The cast doesn't actually fix any potential bug. It just causes the function to get an signed overflow value.