From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-ed1-f48.google.com (mail-ed1-f48.google.com [209.85.208.48]) by mx.groups.io with SMTP id smtpd.web10.11491.1675333307236260441 for ; Thu, 02 Feb 2023 02:21:47 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=X7LyXwMP; spf=pass (domain: gmail.com, ip: 209.85.208.48, mailfrom: savvamtr@gmail.com) Received: by mail-ed1-f48.google.com with SMTP id cw4so1437261edb.13 for ; Thu, 02 Feb 2023 02:21:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=sZqbBGb9oyS44JqrVK9H243Na8Ip04d3FgIvb7+hUvA=; b=X7LyXwMPquAxqE+4NHV5epm2JwpBa4yN1sA3RZs7uw0JvwxCrBR/3mkWyDIbOhGCQA Z9rcg4kVhsyL6CxMc4p5oitYq0zz2R/0qGKYWE5o+YDT03NQZIhY1n9EzE7oyRyVaxJK MewKbMb6RdqSGhN015IITLJG0bjFmHOlDNrB+fxcm2UuzWfLU7Q3J9F67qQ4MHVBKAfa 5r3tTlCzQaZhCMBSZwr2t2RIhx2Z4VPwjLzUzVR1nvSkytUQM0Hyuf6NBpqplk67yiyd Th+0o1SQDSO4fYE6B/lX8Tct4LKJinegCPTV1O7dBJXtZM8VeQKFjsq3JihkuHSKd+Pr Zxhg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=sZqbBGb9oyS44JqrVK9H243Na8Ip04d3FgIvb7+hUvA=; b=eMfswk1Ofo3lUfkEO1IK5A85v7iSuIf7tTPMJZHqkimdkAlrG3wfnULSjVzOMiRjL3 Emoymhw5etpYd4c8C0CWcNnIvAfzwdMHWSVDHLMkWbCZF4yZ4zR8tol3e3DzZnYsjlzv l1nxiUMtWBfEdIgHIa32kKM2QuE5jD4nwn3XDRxe/hTb1utsgNHTztt6tDkV+tC1Q4Gf ZYqpJMjR/carTnVQxxErfp5ZwXB4JJccbJBPfDj1lXH97NkELh481fBx91hMxuGyTK9t JtG5ZTMpkvVRIKi0UQh/JsoEyab17iGrz6TnX7Sb/ZP6E0nQMbCwy6bULqsND7VbYeMp Ax6A== X-Gm-Message-State: AO0yUKWw+ZTbBaSK53flXQWFdfhtGhzRLzd7QGEiM3Q1sX/5VMV3+hYN fgW3VynxlQIFtnwi8ZzSO7RGIgFPZ/vJvw== X-Google-Smtp-Source: AK7set+FyBLMcsanAJAnx4P9r3yH0FTAl3bAGLdnu5oFnE1nW4IsKZ9+5yA2J49h08mbw+Ig17Mkyw== X-Received: by 2002:a05:6402:1207:b0:49e:351b:5ab3 with SMTP id c7-20020a056402120700b0049e351b5ab3mr5597988edw.6.1675333305591; Thu, 02 Feb 2023 02:21:45 -0800 (PST) Return-Path: Received: from localhost.localdomain ([176.62.67.29]) by smtp.gmail.com with ESMTPSA id ci22-20020a170906c35600b0087bcda2b07bsm10013121ejb.202.2023.02.02.02.21.44 (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256); Thu, 02 Feb 2023 02:21:45 -0800 (PST) From: "Savva Mitrofanov" To: devel@edk2.groups.io Cc: =?UTF-8?q?Marvin=20H=C3=A4user?= , Pedro Falcato , Vitaly Cheptsov Subject: [edk2-platforms][PATCH v4 08/12] Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName Date: Thu, 2 Feb 2023 16:21:29 +0600 Message-Id: <20230202102133.51606-9-savvamtr@gmail.com> X-Mailer: git-send-email 2.39.1 In-Reply-To: <20230202102133.51606-1-savvamtr@gmail.com> References: <20230202102133.51606-1-savvamtr@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Missing check in some cases leads to failed StrCpyS call in Ext4GetVolumeLabelInfo. Also correct condition that checks Inode pointer for being NULL in Ext4AllocateInode Cc: Marvin H=C3=A4user Cc: Pedro Falcato Cc: Vitaly Cheptsov Fixes: cfbbae595eec ("Ext4Pkg: Add handling of EFI_FILE_SYSTEM_VOLUME_LABEL= GetInfo().") Signed-off-by: Savva Mitrofanov Reviewed-by: Pedro Falcato Reviewed-by: Marvin H=C3=A4user --- Features/Ext4Pkg/Ext4Dxe/File.c | 10 ++++++++-- Features/Ext4Pkg/Ext4Dxe/Inode.c | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Features/Ext4Pkg/Ext4Dxe/File.c b/Features/Ext4Pkg/Ext4Dxe/Fil= e.c index 9dde4a5d1a2d..677caf88fbdc 100644 --- a/Features/Ext4Pkg/Ext4Dxe/File.c +++ b/Features/Ext4Pkg/Ext4Dxe/File.c @@ -719,7 +719,11 @@ Ext4GetVolumeName ( =0D VolNameLength =3D StrLen (VolumeName);=0D } else {=0D - VolumeName =3D AllocateZeroPool (sizeof (CHAR16));=0D + VolumeName =3D AllocateZeroPool (sizeof (CHAR16));=0D + if (VolumeName =3D=3D NULL) {=0D + return EFI_OUT_OF_RESOURCES;=0D + }=0D +=0D VolNameLength =3D 0;=0D }=0D =0D @@ -786,7 +790,9 @@ Ext4GetFilesystemInfo ( Info->VolumeSize =3D MultU64x32 (TotalBlocks, Part->BlockSize);=0D Info->FreeSpace =3D MultU64x32 (FreeBlocks, Part->BlockSize);=0D =0D - StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);=0D + Status =3D StrCpyS (Info->VolumeLabel, VolNameLength + 1, VolumeName);=0D +=0D + ASSERT_EFI_ERROR (Status);=0D =0D FreePool (VolumeName);=0D =0D diff --git a/Features/Ext4Pkg/Ext4Dxe/Inode.c b/Features/Ext4Pkg/Ext4Dxe/In= ode.c index e44b5638599f..90e3eb88f523 100644 --- a/Features/Ext4Pkg/Ext4Dxe/Inode.c +++ b/Features/Ext4Pkg/Ext4Dxe/Inode.c @@ -230,7 +230,7 @@ Ext4AllocateInode ( =0D Inode =3D AllocateZeroPool (InodeSize);=0D =0D - if (!Inode) {=0D + if (Inode =3D=3D NULL) {=0D return NULL;=0D }=0D =0D --=20 2.39.1