From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-lf1-f47.google.com (mail-lf1-f47.google.com [209.85.167.47]) by mx.groups.io with SMTP id smtpd.web10.44810.1670856431021873589 for ; Mon, 12 Dec 2022 06:47:11 -0800 Authentication-Results: mx.groups.io; dkim=pass header.i=@gmail.com header.s=20210112 header.b=DjtLDLSH; spf=pass (domain: gmail.com, ip: 209.85.167.47, mailfrom: savvamtr@gmail.com) Received: by mail-lf1-f47.google.com with SMTP id p8so18950657lfu.11 for ; Mon, 12 Dec 2022 06:47:10 -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=NIHGR1jKnx3AI9rbZHWa0tNIbbSLaTaQPdVK/0qpuk0=; b=DjtLDLSHcaNkdvnvucDNlMd3hUynXbBjdgYo5wIkFwZD32002/MwXFAi1EWcTSw1Ap cQzKNAUC+o9sLa1jCXlebVOnsxPfUDMZuEFfqf+ZjK121ZPBnykVrW/9zLIRMaotXsLH BJvKjmbstOnTYaeA5TTPkXyZ7Ij3hII79I1k9CqnR/zsd5Cl0Q7jtBUDAZpUGHWv5c03 gu5so0jV4PeSFMmCQLFwchwm3igqoCSU+1NUeG+blKAzgJLtHhd53LBFSZutRKegfk5d SBHO0foJx3B8/8lpeZUQ6QjqhrGlgzWhsYOr4JM2ohoV1WnKmkwpXwED3ac4kqx0i/vk 1/Rw== 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=NIHGR1jKnx3AI9rbZHWa0tNIbbSLaTaQPdVK/0qpuk0=; b=hSTYPij2nQM9U18/x85b2l47rDVXXCf+pQuMNISouADY8H0s4g/jCONSPxlIDLl2WK hzbiM4hZvkgZmgS4nRVw4Qyvjt7ISR9wCL5J520yauLz4o6E0Oa60MTbkfo6DwX3a60Z LzWciYW42/XZlposhGwbDyfXrp2nXXmwejHAVKbvkf/lnL4OHphEXHR0Xr305DOxos/y NvzdZG53hCuYHvjS6cPXGqyQEtSkf9n54C9F86SNcCVTZk99TxHdq91JfBEm8fQOQ5kG n0ElWPa0IV44Bx2ouooxokXTv0uHGIshfsc1rYm68n9HluRsi0nKJWPWgEge2Nk3jBTo y1gg== X-Gm-Message-State: ANoB5pmcXqUqX1jq7p+lRQreJ2tM4bsOW886qx1zsV5k+FfkGz4NFLRW h/tp9kToLx6Ln299pIX2Nb5KuP6F57V8F4k1 X-Google-Smtp-Source: AA0mqf4gA7I0zVKKyWlEg608DGJ1eTlfsW/Xo4riL6vhJ4lQcehGR4IhVx1aNPjuYfL3IumlFQ9h5g== X-Received: by 2002:a05:6512:3c88:b0:4b5:2f1e:7d3b with SMTP id h8-20020a0565123c8800b004b52f1e7d3bmr6009314lfv.33.1670856429197; Mon, 12 Dec 2022 06:47:09 -0800 (PST) Return-Path: Received: from localhost.localdomain ([77.221.215.144]) by smtp.gmail.com with ESMTPSA id t4-20020a056512030400b0049c29292250sm1643313lfp.149.2022.12.12.06.47.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Dec 2022 06:47:08 -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 v2 10/11] Ext4Pkg: Check VolumeName allocation correctness in Ext4GetVolumeName Date: Mon, 12 Dec 2022 20:46:53 +0600 Message-Id: <20221212144654.2650-11-savvamtr@gmail.com> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221212144654.2650-1-savvamtr@gmail.com> References: <20221212144654.2650-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: e55f0527dde48a5f139c1b8f35acc4e6b59dd794 Signed-off-by: Savva Mitrofanov --- 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 20a0194a5793..085cb7236957 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 5ccb4d2bfc42..2977238d687c 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.38.1