From nobody Sun May 19 01:15:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42969+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42969+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1561696153; cv=none; d=zoho.com; s=zohoarc; b=McWkHVdfVpC4C36Wf+JivLGOoYen6q7LzKNDrURyNW9G3RFNiPZI3YID4wQMOV+KTdTChDuHmEJuScdNc6PngqCJVaq2VoMjpRBBX/mVb5dwrLPQ/CQcHvbIVhbT6P9T8Vf8TDq7evZJzkv9ksdcjJYF0NdrsNzTjXtUK5QCDqU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561696153; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=vroaQBHxN6J+hbDD4svnSQ4IDVp3o+YdNHdUHit0v8k=; b=Vf6ww53tLziMdFgNqqgQ4uTAkWzK53ADWuR+RE+INfX/so142+dxgmMvlJia0QqHLzGfnBYExrlhWBeBCx7VQLIso1RAzzxPoTEzc4rfT6huUMQRaPJx/NQ9yrwDcAW3mkRs6zfyk6WETR4ZHp2k3dCxH87YwSevduTYTn19Ygk= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42969+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 156169615349179.17643369707116; Thu, 27 Jun 2019 21:29:13 -0700 (PDT) Return-Path: X-Received: from mga18.intel.com (mga18.intel.com []) by groups.io with SMTP; Thu, 27 Jun 2019 21:29:11 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 20:58:01 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,426,1557212400"; d="scan'208";a="183599680" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 27 Jun 2019 20:57:59 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao Subject: [edk2-devel] [PATCH 1/3] MdePkg/BaseLib: Adjust the coding style in Base64Decode Date: Fri, 28 Jun 2019 11:57:44 +0800 Message-Id: <20190628035746.24160-2-zhichao.gao@intel.com> In-Reply-To: <20190628035746.24160-1-zhichao.gao@intel.com> References: <20190628035746.24160-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1561696151; bh=715R7vGjcT5L0F+JhDOrPfEQfPa2FmWNj9mdjxzBFMk=; h=Cc:Date:From:Reply-To:Subject:To; b=iT1ht0N7qah4IriVI1UHkaowU1+TxsGFcKZLwd+WqdkW87NEOmLmqONt7cdCnj+XemU /eQFfBuDTzhzmQ5XDLiN9m2jeetBtrQ/KGU1/+fOxedLxzNQr47oL3bleseEqYCubazHP 7++aQ+M5Pc8M9UIE6vOMzRd2kXvZQnGnnqs= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" Adjust the code style for better view. Cc: Michael D Kinney Cc: Liming Gao Signed-off-by: Zhichao Gao Reviewed-by: Laszlo Ersek --- MdePkg/Library/BaseLib/String.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/Strin= g.c index 32e189791c..b86e7e9436 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -1993,8 +1993,7 @@ Base64Decode ( if (BufferSize < -2) { return RETURN_INVALID_PARAMETER; } - } - else { + } else { Chr =3D Source[SourceIndex]; if (BAD_V !=3D DecodingTable[(UINT8) Chr]) { =20 @@ -2006,8 +2005,7 @@ Base64Decode ( return RETURN_INVALID_PARAMETER; } ActualSourceLength++; - } - else { + } else { =20 // // The reset of the decoder will ignore all invalid characters all= owed here. @@ -2029,8 +2027,8 @@ Base64Decode ( } =20 BufferSize +=3D ActualSourceLength / 4 * 3; - if (BufferSize < 0) { - return RETURN_INVALID_PARAMETER; + if (BufferSize < 0) { + return RETURN_INVALID_PARAMETER; } =20 // @@ -2061,7 +2059,7 @@ Base64Decode ( // for (Index =3D 0; Index < 4; Index++) { do { - Chr =3D DecodingTable[(UINT8) Source[SourceIndex++]]; + Chr =3D DecodingTable[(UINT8) Source[SourceIndex++]]; } while (Chr =3D=3D BAD_V); Value <<=3D 6; Value |=3D (UINT32)Chr; --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#42969): https://edk2.groups.io/g/devel/message/42969 Mute This Topic: https://groups.io/mt/32238988/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 19 01:15:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42970+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42970+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1561696153; cv=none; d=zoho.com; s=zohoarc; b=Zk5YUOmQeezf2xYyQUDlOJIA4OuRnTov0P9v/PizwoHhhSBC4KDYXdqq8RJONvlk4AAJ7gtvI+gjt6MAk5y0FGIqvHIezMulSsxG249aZCf/S1ai2GWT0tiCIDHvSRNRKbe8shITFeGYXiwtXSSRAdnxb9SchMCYe2/jqrvOPqw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561696153; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=dUPvGih5mWVFn2a38axIpbrFLhqbM1noDwtkCeqM+Kw=; b=Z6ng8ghzJVkLbaj2en5ECBsIKH+y3YPA57cERT3Y4pobwu1bKkPteCG2XdZ8MDqmceSwF3r3dFP4XOM73ccGTBDPF8W7/HMj7nIsTAjFfZggsnKTn2gNMSx5l1QU5KlRUvqUXOLWFdAiwGOXDSmooKczz7z4xRRqF6FiwfwGlks= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42970+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1561696153731901.7654805827841; Thu, 27 Jun 2019 21:29:13 -0700 (PDT) Return-Path: X-Received: from mga18.intel.com (mga18.intel.com []) by groups.io with SMTP; Thu, 27 Jun 2019 21:29:11 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 20:58:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,426,1557212400"; d="scan'208";a="183599687" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 27 Jun 2019 20:58:00 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Marvin Hauser , Laszlo Ersek Subject: [edk2-devel] [PATCH 2/3] MdePkg/BaseLib: Base64Decode: Make DestinationSize complied to spec Date: Fri, 28 Jun 2019 11:57:45 +0800 Message-Id: <20190628035746.24160-3-zhichao.gao@intel.com> In-Reply-To: <20190628035746.24160-1-zhichao.gao@intel.com> References: <20190628035746.24160-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1561696152; bh=i4ZbBYDziNCvYyrUp0LO4tCluOP8A98f4UcKqV3PhHA=; h=Cc:Date:From:Reply-To:Subject:To; b=WT0ql5Hk5w/ApkqnrjHKfhl9ZEiFCgL6j7P1VkBQ9GIy3sggfFso/5kuzYeR97z4ONp ySWDx7M9a3i8umO7oPaaqlBrGY4BwemSSjZAHo/mS95z92AxvqizyX135DN5XQnREgrBR VCbbJUJtSpXXSkFaJq4RCOgwVhGYVs1ucs4= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1891 DestinationSize is decripted as 'Set to bytes stored on return'. Before return the status, set its converted bytes to be complied to the decriptions. DestinationIndex may be overflow if the *DestinationSize is bigger than (MAX_ADDRESS - 1). Move its incrementation under condition 'DestinationIndex < *DestinationSize' to make sure it wouldn't be overflow. Cc: Michael D Kinney Cc: Liming Gao Cc: Marvin Hauser Cc: Laszlo Ersek Signed-off-by: Zhichao Gao --- MdePkg/Library/BaseLib/String.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/Strin= g.c index b86e7e9436..7ebc2ecddd 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -1964,6 +1964,7 @@ Base64Decode ( // Check if SourceLength or DestinationSize is valid // if ((SourceLength >=3D (MAX_ADDRESS - (UINTN)Source)) || (*DestinationSi= ze >=3D (MAX_ADDRESS - (UINTN)Destination))){ + *DestinationSize =3D 0; return RETURN_INVALID_PARAMETER; } =20 @@ -1991,6 +1992,7 @@ Base64Decode ( // Only two '=3D' characters can be valid. // if (BufferSize < -2) { + *DestinationSize =3D 0; return RETURN_INVALID_PARAMETER; } } else { @@ -2002,6 +2004,7 @@ Base64Decode ( // valid character after an '=3D', will be flagged as an error. // if (BufferSize < 0) { + *DestinationSize =3D 0; return RETURN_INVALID_PARAMETER; } ActualSourceLength++; @@ -2013,6 +2016,7 @@ Base64Decode ( // ignore ' ', '\t', '\n', and '\r'. // if ((Chr !=3D ' ') &&(Chr !=3D '\t') &&(Chr !=3D '\n') &&(Chr !=3D= '\r')) { + *DestinationSize =3D 0; return RETURN_INVALID_PARAMETER; } } @@ -2023,11 +2027,13 @@ Base64Decode ( // The Base64 character string must be a multiple of 4 character quantum= s. // if (ActualSourceLength % 4 !=3D 0) { + *DestinationSize =3D 0; return RETURN_INVALID_PARAMETER; } =20 BufferSize +=3D ActualSourceLength / 4 * 3; if (BufferSize < 0) { + *DestinationSize =3D 0; return RETURN_INVALID_PARAMETER; } =20 @@ -2075,13 +2081,16 @@ Base64Decode ( // Due to the '=3D' special cases for the two bytes at the end, // we have to check the length and not store the padding data // - if (DestinationIndex++ < *DestinationSize) { + if (DestinationIndex < *DestinationSize) { + DestinationIndex++; *Destination++ =3D (UINT8) (Value >> 8); } - if (DestinationIndex++ < *DestinationSize) { + if (DestinationIndex < *DestinationSize) { + DestinationIndex++; *Destination++ =3D (UINT8) Value; } } + *DestinationSize =3D DestinationIndex; =20 return RETURN_SUCCESS; } --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#42970): https://edk2.groups.io/g/devel/message/42970 Mute This Topic: https://groups.io/mt/32238989/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- From nobody Sun May 19 01:15:23 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) client-ip=66.175.222.12; envelope-from=bounce+27952+42971+1787277+3901457@groups.io; helo=web01.groups.io; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42971+1787277+3901457@groups.io; dmarc=fail(p=none dis=none) header.from=intel.com ARC-Seal: i=1; a=rsa-sha256; t=1561696153; cv=none; d=zoho.com; s=zohoarc; b=awB8mMZK3hcbTHiV77o1UqOqoUiifpJdQmIlAkUFd+AGIzLAk6fwdmaTSDrJlRNhWBKELn50rYhbpAEhp2JQdUr4hsgvtTmXowLXE02YjW67/qeQlZxwhRBgABqqpIEKoZ3YUvWRmmc6a7QP9M/Gq06Ln/6Kb5Y6kALcLrgSuBc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561696153; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Id:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:References:Sender:Subject:To:ARC-Authentication-Results; bh=aWpgJ7Bcbm7gxU5ZGM6LW1XZAPneDM/0QQ2B+qKcHQA=; b=ifWKhrzlBwnD4D2rvJ5igaSIxAlnm9X/TYiMwB0D4Wx2w+5YaI5qr2Eb5d/KZf2V3d+JXhAyfhTpNBioI2viLRoGVnkRJyx0nwukL9vWj69PtyEKgu/gLQYui64+t4AJ8YejF2D/GxUGYzuD4bKIDVZ4eOzs3GF9EWrmgmwI7cA= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=pass; spf=pass (zoho.com: domain of groups.io designates 66.175.222.12 as permitted sender) smtp.mailfrom=bounce+27952+42971+1787277+3901457@groups.io; dmarc=fail header.from= (p=none dis=none) header.from= Received: from web01.groups.io (web01.groups.io [66.175.222.12]) by mx.zohomail.com with SMTPS id 1561696153741719.0606372278247; Thu, 27 Jun 2019 21:29:13 -0700 (PDT) Return-Path: X-Received: from mga18.intel.com (mga18.intel.com []) by groups.io with SMTP; Thu, 27 Jun 2019 21:29:12 -0700 X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False X-Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by orsmga106.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 27 Jun 2019 20:58:03 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.63,426,1557212400"; d="scan'208";a="183599691" X-Received: from fieedk001.ccr.corp.intel.com ([10.239.33.119]) by fmsmga001.fm.intel.com with ESMTP; 27 Jun 2019 20:58:01 -0700 From: "Gao, Zhichao" To: devel@edk2.groups.io Cc: Michael D Kinney , Liming Gao , Laszlo Ersek Subject: [edk2-devel] [PATCH 3/3] MdePkg/BaseLib: Base64Decode: Add decription for RETURN_SUCCESS Date: Fri, 28 Jun 2019 11:57:46 +0800 Message-Id: <20190628035746.24160-4-zhichao.gao@intel.com> In-Reply-To: <20190628035746.24160-1-zhichao.gao@intel.com> References: <20190628035746.24160-1-zhichao.gao@intel.com> MIME-Version: 1.0 Precedence: Bulk List-Unsubscribe: Sender: devel@edk2.groups.io List-Id: Mailing-List: list devel@edk2.groups.io; contact devel+owner@edk2.groups.io Reply-To: devel@edk2.groups.io,zhichao.gao@intel.com Content-Transfer-Encoding: quoted-printable DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=groups.io; q=dns/txt; s=20140610; t=1561696153; bh=WMkdBzvHhmZylhSCDbly7KHTQBQcKEgDRZCuEc4b+eI=; h=Cc:Date:From:Reply-To:Subject:To; b=AazoqC4Z3N+Ane542E5i3jPOhokgqSlmKf5z3vP8TYPQbjusuXjs9O1aPuehMjEEPnh f1Cjpglx9fUuiR4dwZq2EEfCaP1+cv35IgrI9tBK7ZNnrehOXl+UVKJg7K+6bh7MiBDCh moa75mtn544lCp360rR0WBz6ZRHHwvTEpXo= X-ZohoMail-DKIM: pass (identity @groups.io) Content-Type: text/plain; charset="utf-8" REF: https://bugzilla.tianocore.org/show_bug.cgi?id=3D1891 While the convertion Base64 ascii string is null string (the string only contain white space would be regard as null string), there would be no decodeable data. Set *DestinationSize to zero and return RETURN_SUCCESS. But it is not mention in the comment of the function. So add this decription. Cc: Michael D Kinney Cc: Liming Gao Cc: Laszlo Ersek Signed-off-by: Zhichao Gao --- MdePkg/Library/BaseLib/String.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/MdePkg/Library/BaseLib/String.c b/MdePkg/Library/BaseLib/Strin= g.c index 7ebc2ecddd..8829d2cbbf 100644 --- a/MdePkg/Library/BaseLib/String.c +++ b/MdePkg/Library/BaseLib/String.c @@ -1929,7 +1929,8 @@ Base64Encode ( @param DestinationSize Caller is responsible for passing in buffer of = at least DestinationSize. Set 0 to get the size needed. Set to bytes stor= ed on return. =20 - @retval RETURN_SUCCESS When binary buffer is filled in. + @retval RETURN_SUCCESS When binary buffer is filled in. Or i= f the Base64 ascii string is empty, set + *DestinationSize to zero to indicate = this case. @retval RETURN_INVALID_PARAMETER If Source is NULL or DestinationSize = is NULL. @retval RETURN_INVALID_PARAMETER If SourceLength or DestinationSize is= bigger than (MAX_ADDRESS -(UINTN)Destination ). @retval RETURN_INVALID_PARAMETER If there is any invalid character in = input stream. --=20 2.21.0.windows.1 -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D- Groups.io Links: You receive all messages sent to this group. View/Reply Online (#42971): https://edk2.groups.io/g/devel/message/42971 Mute This Topic: https://groups.io/mt/32238990/1787277 Group Owner: devel+owner@edk2.groups.io Unsubscribe: https://edk2.groups.io/g/devel/unsub [importer@patchew.org] -=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-=3D-