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 mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4114BC433F5 for ; Thu, 30 Sep 2021 15:18:14 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id A2F7D615E5 for ; Thu, 30 Sep 2021 15:18:13 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org A2F7D615E5 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=lists.denx.de Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 9D8E781FED; Thu, 30 Sep 2021 17:18:11 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 8EB1D81FEC; Thu, 30 Sep 2021 17:18:09 +0200 (CEST) Received: from bhuna.collabora.co.uk (bhuna.collabora.co.uk [IPv6:2a00:1098:0:82:1000:25:2eeb:e3e3]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id B9BB481FEC for ; Thu, 30 Sep 2021 17:18:05 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=ariel.dalessandro@collabora.com Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: adalessandro) with ESMTPSA id 3AE201F44EF7 Subject: Re: [PATCH] fastboot: mmc: Fix dest size in strlcat() To: Sean Anderson , u-boot@lists.denx.de Cc: seanga2@gmail.com, sjg@chromium.org, m.szyprowski@samsung.com, r.stratiienko@gmail.com, patrick.delaunay@foss.st.com, oleg@kaa.org.ua References: <20210930134740.2451149-1-ariel.dalessandro@collabora.com> From: Ariel D'Alessandro Message-ID: Date: Thu, 30 Sep 2021 12:17:57 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: 8bit X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.34 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.2 at phobos.denx.de X-Virus-Status: Clean Hi Sean, On 9/30/21 12:15 PM, Sean Anderson wrote: > > > > On 9/30/21 9:47 AM, Ariel D'Alessandro wrote: >> strlcat() is truncating the destination string to the size of the source >> string. Fix size argument in strlcat() to match the size of destination >> buffer. >> >> Bug was introduced in the following commit: >> >> commit 69a752983171c2983fc1f29c7cfa1844f41e5d8b >> Author: Sean Anderson >> >>      fastboot: Fix possible buffer overrun >> >> Signed-off-by: Ariel D'Alessandro >> --- >>   drivers/fastboot/fb_mmc.c | 4 ++-- >>   1 file changed, 2 insertions(+), 2 deletions(-) >> >> diff --git a/drivers/fastboot/fb_mmc.c b/drivers/fastboot/fb_mmc.c >> index cbb3f7b1dea..4c54f0c3893 100644 >> --- a/drivers/fastboot/fb_mmc.c >> +++ b/drivers/fastboot/fb_mmc.c >> @@ -40,7 +40,7 @@ static int raw_part_get_info_by_name(struct blk_desc >> *dev_desc, >> >>       /* check for raw partition descriptor */ >>       strcpy(env_desc_name, "fastboot_raw_partition_"); >> -    strlcat(env_desc_name, name, PART_NAME_LEN); >> +    strlcat(env_desc_name, name, ARRAY_SIZE(env_desc_name)); >>       raw_part_desc = strdup(env_get(env_desc_name)); >>       if (raw_part_desc == NULL) >>           return -ENODEV; >> @@ -114,7 +114,7 @@ static int part_get_info_by_name_or_alias(struct >> blk_desc **dev_desc, >> >>           /* check for alias */ >>           strcpy(env_alias_name, "fastboot_partition_alias_"); >> -        strlcat(env_alias_name, name, PART_NAME_LEN); >> +        strlcat(env_alias_name, name, ARRAY_SIZE(env_alias_name)); >>           aliased_part_name = env_get(env_alias_name); >>           if (aliased_part_name != NULL) >>               ret = do_get_part_info(dev_desc, aliased_part_name, >> > > This looks like a duplicate of [1]. I think the only difference is > ARRAY_SIZE vs sizeof, but they are equivalent since sizeof(char) == 1. Ah, you're right. Sorry I missed that patch. > > --Sean > > [1] > http://patchwork.ozlabs.org/project/uboot/patch/20210730122354.6281-1-matthias.schiffer@ew.tq-group.com/ >