From patchwork Mon Jan 25 23:04:19 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heinrich Schuchardt X-Patchwork-Id: 1431424 X-Patchwork-Delegate: trini@ti.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=85.214.62.61; helo=phobos.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.a=rsa-sha256 header.s=badeba3b8450 header.b=NliXQNUl; dkim-atps=neutral Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4DPlnD38L8z9s1l for ; Tue, 26 Jan 2021 10:04:43 +1100 (AEDT) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 36AD7824A4; Tue, 26 Jan 2021 00:04:33 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=fail (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (1024-bit key; secure) header.d=gmx.net header.i=@gmx.net header.b="NliXQNUl"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id ABAFD8250D; Tue, 26 Jan 2021 00:04:31 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,FREEMAIL_FROM,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H2, SPF_HELO_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from mout.gmx.net (mout.gmx.net [212.227.17.21]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 31B8E80829 for ; Tue, 26 Jan 2021 00:04:29 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=gmx.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=xypron.glpk@gmx.de DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=gmx.net; s=badeba3b8450; t=1611615863; bh=UwSQ4DzAChkljiIkbye87NPtis3z+9Ay3d3hJwi38+4=; h=X-UI-Sender-Class:From:To:Cc:Subject:Date; b=NliXQNUlimO5TcLOTrCe6gBEXJHlgwRD7a0ssbHetq0SEalH+82TuL07OP4GmvqWe bj8MWMUex2zxg80gaLJX2YGHIMVG4YdO+jvwlWGSR+D82CXHDLoqVl1ymNNKhQAesQ 2LjrmcKLGRN6HwfQI4gXqxLsseKfOx9BmH6KgtBI= X-UI-Sender-Class: 01bb95c1-4bf8-414a-932a-4f6e2808ef9c Received: from LT02.fritz.box ([62.143.246.89]) by mail.gmx.net (mrgmx105 [212.227.17.174]) with ESMTPSA (Nemesis) id 1MGQj7-1lDq4Q2SzN-00Gn3o; Tue, 26 Jan 2021 00:04:23 +0100 From: Heinrich Schuchardt To: Tom Rini Cc: Heinrich Schuchardt , Marek Szyprowski , u-boot@lists.denx.de Subject: [PATCH 1/1] fs: fat: avoid out of bounds access warning Date: Tue, 26 Jan 2021 00:04:19 +0100 Message-Id: <20210125230419.58933-1-xypron.glpk@gmx.de> X-Mailer: git-send-email 2.29.2 MIME-Version: 1.0 X-Provags-ID: V03:K1:W82FixZazbV0gQVNzmHVXzuBYWmATJXVoaien81ZBG5xpmtCgrq 6fsVFhCWbbtV8DNJLEO7Xhvx0j4nCOYqCZZbwwHf61Cc1MucXx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HGUyOE8MHQ== 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.102.3 at phobos.denx.de X-Virus-Status: Clean When copying short name plus extension refer to the encapsulating structure and not to the short name element. Signed-off-by: Heinrich Schuchardt --- fs/fat/fat_write.c | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) -- 2.29.2 diff --git a/fs/fat/fat_write.c b/fs/fat/fat_write.c index 0132ef9b42..aae3a6a3d1 100644 --- a/fs/fat/fat_write.c +++ b/fs/fat/fat_write.c @@ -108,10 +108,7 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname) char buf[13]; int i; int ret; - struct { - char name[8]; - char ext[3]; - } dirent; + struct nameext dirent; if (!filename) return -EIO; @@ -185,7 +182,7 @@ static int set_name(fat_itr *itr, const char *filename, char *shortname) } return -EIO; out: - memcpy(shortname, dirent.name, SHORT_NAME_SIZE); + memcpy(shortname, &dirent, SHORT_NAME_SIZE); return ret; }