public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: edk2-devel-groups-io <devel@edk2.groups.io>
Cc: "Ard Biesheuvel" <ard.biesheuvel@linaro.org>,
	"Jordan Justen" <jordan.l.justen@intel.com>,
	"Philippe Mathieu-Daudé" <philmd@redhat.com>
Subject: [PATCH v2] OvmfPkg/EnrollDefaultKeys: clean up Base64Decode() retval handling
Date: Wed,  4 Sep 2019 09:52:33 +0200	[thread overview]
Message-ID: <20190904075233.5005-1-lersek@redhat.com> (raw)

Since commit 35e242b698cd ("MdePkg/BaseLib: rewrite Base64Decode()",
2019-07-16), Base64Decode() guarantees that DestinationSize is larger on
output than it was on input if RETURN_BUFFER_TOO_SMALL is returned. Clean
up the retval handling for the first Base64Decode() call in
EnrollDefaultKeys, which used to work around the ambiguity in the previous
Base64Decode() interface contract.

Cc: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Cc: Jordan Justen <jordan.l.justen@intel.com>
Cc: Philippe Mathieu-Daudé <philmd@redhat.com>
Ref: https://bugzilla.tianocore.org/show_bug.cgi?id=1981
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Philippe Mathieu-Daude <philmd@redhat.com>
---

Notes:
    v2:
    
    - Repo:   https://github.com/lersek/edk2.git
      Branch: enroll_base64_cleanup_bz1981_v2
    
    - pick up Phil's R-b:
      http://mid.mail-archive.com/d7e733d7-d32f-02ec-98ec-c121d6b406e0@redhat.com
      https://edk2.groups.io/g/devel/message/43771
    
    - update BZ reference from TianoCore#1891 to TianoCore#1981 (due to the
      patch being split off of the original series linked at
      <https://bugzilla.tianocore.org/show_bug.cgi?id=1891#c7>:
      <http://mid.mail-archive.com/20190702102836.27589-1-lersek@redhat.com>)
    
    - refer to the specific commit hash of patch "MdePkg/BaseLib: rewrite
      Base64Decode()" in the commit message
    
    - no code changes

 OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c b/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
index f45cb799f726..302b80d97720 100644
--- a/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
+++ b/OvmfPkg/EnrollDefaultKeys/EnrollDefaultKeys.c
@@ -153,16 +153,10 @@ GetPkKek1 (
   DecodedCertSize = 0;
   Status = Base64Decode (Base64Cert, Base64CertLen, NULL, &DecodedCertSize);
   switch (Status) {
   case EFI_BUFFER_TOO_SMALL:
-    if (DecodedCertSize > 0) {
-      break;
-    }
-    //
-    // Fall through: the above Base64Decode() call is ill-specified in BaseLib
-    // if Source decodes to zero bytes (for example if it consists of ignored
-    // whitespace only).
-    //
+    ASSERT (DecodedCertSize > 0);
+    break;
   case EFI_SUCCESS:
     AsciiPrint ("error: empty certificate after app prefix %g\n",
       &gOvmfPkKek1AppPrefixGuid);
     return EFI_PROTOCOL_ERROR;
-- 
2.19.1.3.g30247aa5d201


             reply	other threads:[~2019-09-04  7:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-04  7:52 Laszlo Ersek [this message]
2019-09-04 12:37 ` [PATCH v2] OvmfPkg/EnrollDefaultKeys: clean up Base64Decode() retval handling Ard Biesheuvel
2019-09-05 17:34   ` [edk2-devel] " Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20190904075233.5005-1-lersek@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox