Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 86F3BECAAD8 for ; Fri, 26 Aug 2022 21:16:19 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id E8351848C1; Fri, 26 Aug 2022 23:16:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=denx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1661548572; bh=ZZE4fY9pLRAiHNL8PgTUA4Ir55yMVk7qVWwOIyhBK9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-Id: List-Unsubscribe:List-Archive:List-Post:List-Help:List-Subscribe: From; b=otiWN2HpPmp4CGVTvyKi/xKE521Y4hDeMs8e6fxA4dBpQ+hhLMXGToOAG7lBFdZsb NXo93a6knROQ6oqPj6eYjkEiZ7WVhur1DwnRtrFvs7cb1e1BJdDh+Gn7bVn7saQcPB 9qxa3wvseBVmqyJjl3L5R250NGrQ6JRXm2PNPRY7AgpxfVl44GtKETbKiyLpzsAx2o T1LdYykq0Z0PtwNY9FyLjJK+8KWFIjYOQGfRq+O06PtIKWXD0waYmczKF8od+F4NMD DZxoI5be3Yx9QoeIe9hr7Zl/UfpPugmT4zVM5Talqbj+v/CPkEHvW8ff6AdOGJIiJt 4fLa8jrKYubSg== Received: from tr.lan (ip-86-49-12-201.bb.vodafone.cz [86.49.12.201]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) (Authenticated sender: marex@denx.de) by phobos.denx.de (Postfix) with ESMTPSA id C8623841F5; Fri, 26 Aug 2022 23:16:05 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=denx.de; s=phobos-20191101; t=1661548566; bh=ZZE4fY9pLRAiHNL8PgTUA4Ir55yMVk7qVWwOIyhBK9c=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cAoFhXKbwMxsyYjTotNcBgKWxzs95+aO/IxmB7X4C7R83/RolWezBl+EonUndPFYJ OLLFyqH4GdkzlHUUJXuYNI4C96op80VCkkcsFw6k/GtSmknCiH+slTgoGcJKNcjYtK dLkhfcFKSoXMi2pUKYLp8kbFVMMqmX5JIa3NC4q4qwgs1N1Eg2/REG65JBg6cQO9+C qHFKZ+AdUl+2lVT5FeERhethegjF8Q69evWY2JmhX2FGzUwVHNF41CvdqoPH1mW9KH uSy9f3g0n2RUrxo/gT5kaktLbxZc1KRkaelSbBbDVvKCSZKusdRqUhdLOr1Yjb1tF3 z9I6DH9FJqXvg== From: Marek Vasut To: u-boot@lists.denx.de Cc: Marek Vasut , Heiko Schocher , Nicolas Iooss , Simon Glass , Tim Harvey Subject: [PATCH 2/2] i2c: fix stack buffer overflow vulnerability in i2c md command Date: Fri, 26 Aug 2022 23:15:56 +0200 Message-Id: <20220826211556.23100-2-marex@denx.de> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220826211556.23100-1-marex@denx.de> References: <20220826211556.23100-1-marex@denx.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean This reinstates fix from commit 8f8c04bf1ebbd2f72f1643e7ad9617dafa6e5409 without the changes unrelated to the actual fix. Avoid the underflow by setting only nbytes and linebytes as unsigned integers. Signed-off-by: Marek Vasut Cc: Heiko Schocher Cc: Nicolas Iooss Cc: Simon Glass Cc: Tim Harvey --- cmd/i2c.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cmd/i2c.c b/cmd/i2c.c index 9050b2b8d27..e196a73efa6 100644 --- a/cmd/i2c.c +++ b/cmd/i2c.c @@ -470,7 +470,8 @@ static int do_i2c_md(struct cmd_tbl *cmdtp, int flag, int argc, uint chip; uint addr, length; int alen; - int j, nbytes, linebytes; + int j; + uint nbytes, linebytes; int ret; #if CONFIG_IS_ENABLED(DM_I2C) struct udevice *dev; -- 2.35.1