From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received-SPF: Pass (sender SPF authorized) identity=mailfrom; client-ip=2607:f8b0:4001:c0b::22d; helo=mail-it0-x22d.google.com; envelope-from=ard.biesheuvel@linaro.org; receiver=edk2-devel@lists.01.org Received: from mail-it0-x22d.google.com (mail-it0-x22d.google.com [IPv6:2607:f8b0:4001:c0b::22d]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by ml01.01.org (Postfix) with ESMTPS id 0B4BD202E5CDD for ; Tue, 17 Oct 2017 12:24:34 -0700 (PDT) Received: by mail-it0-x22d.google.com with SMTP id r127so3666019itb.5 for ; Tue, 17 Oct 2017 12:28:11 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=XWnuH3GWQhsVdReP/70dW1evSV8z6P2NbWkAljrzfgQ=; b=Jx4TrJRfdMBNLKlncI4eGp9QyRo6LYpTFuXePbQsvTFz34i1YfdV9yxBQjWMsIQNGj xTI8lSitI6R8jPHkW0H4+Sx6cGqvjJo+H+8mSVG417c3XNY3lf3nsqxoIhBf79dXYoWe ZgWu+ja9TM0wrLyhQomT1OB2Nx24vbYO9be7k= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=XWnuH3GWQhsVdReP/70dW1evSV8z6P2NbWkAljrzfgQ=; b=kwJdsRlW3Fabj6PoUiKj4XTq7113OGTnSGOITb1c7OpSPOOpWeUSnLP6/DjD/tfFKC p+GdSgb7giej976Ql3Ssw8/fGnxeiA7AlohiLacPQQCf+YAzXXdsLyfI7Wwej5ShQxHC qLz6AMMXgBo0OVmUlaK2c9InOMmrbRlm/wHcs3pSkY44A1Ta0A5KDnK74Joy4kcyi2HK XdwkplY0Sj5WsIru84rCIXAQKwVuUI3q0fBgFpXCjaL4W/dLURfKhXMpWBUTuJoS/j/m qcBJ4LAx8KNxJSfRahN9PaAjYDe0gzHwUk0ti58B8nbnMMGvGwvN8IkFFdfNvk4cgnyC HcIA== X-Gm-Message-State: AMCzsaWaeAndAfvVS0b7DumO8/ejtv/ddGPjkOewboTlVtWr7RJDi6Wz B481Y3p/1W/Rf70etBx9zROstoipUTsscYBIhLWChA== X-Google-Smtp-Source: ABhQp+R4VuSBXGMt7ui/W7fCFvnO2a6F5gJ866JVPyGU9BunH76wBa3IHmn9YZiN9RgStZhiopXt9sFjbStgMCYuKJM= X-Received: by 10.36.233.133 with SMTP id f127mr6758200ith.34.1508268490708; Tue, 17 Oct 2017 12:28:10 -0700 (PDT) MIME-Version: 1.0 Received: by 10.107.131.167 with HTTP; Tue, 17 Oct 2017 12:28:09 -0700 (PDT) In-Reply-To: <20171017191646.26065-1-lersek@redhat.com> References: <20171017191646.26065-1-lersek@redhat.com> From: Ard Biesheuvel Date: Tue, 17 Oct 2017 20:28:09 +0100 Message-ID: To: Laszlo Ersek Cc: edk2-devel-01 , Chao Zhang , Gary Lin , Leif Lindholm , Long Qin Subject: Re: [PATCH] SecurityPkg/AuthVariableLib: fix GCC build error X-BeenThere: edk2-devel@lists.01.org X-Mailman-Version: 2.1.22 Precedence: list List-Id: EDK II Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Oct 2017 19:24:35 -0000 Content-Type: text/plain; charset="UTF-8" On 17 October 2017 at 20:16, Laszlo Ersek wrote: > Commit 53c6ff180327 ("SecurityPkg:AuthVariableLib:Implement ECR1707 for > Private Auth Variable", 2017-09-12) introduced the following build > failure under several GCC toolchain versions: > >> SecurityPkg/Library/AuthVariableLib/AuthService.c: In function >> 'CalculatePrivAuthVarSignChainSHA256Digest': >> SecurityPkg/Library/AuthVariableLib/AuthService.c:1567:58: error: >> pointer targets in passing argument 3 of 'X509GetCommonName' differ in >> signedness [-Werror=pointer-sign] >> Status = X509GetCommonName(SignerCert, SignerCertSize, CertCommonName, &CertCommonNameSize); >> ^~~~~~~~~~~~~~ >> In file included from >> SecurityPkg/Library/AuthVariableLib/AuthServiceInternal.h:34:0, >> from >> SecurityPkg/Library/AuthVariableLib/AuthService.c:32: >> CryptoPkg/Include/Library/BaseCryptLib.h:2202:1: note: expected 'CHAR8 * >> {aka char *}' but argument is of type 'UINT8 * {aka unsigned char *}' >> X509GetCommonName ( >> ^~~~~~~~~~~~~~~~~ >> cc1: all warnings being treated as errors > > Fix it by changing the type of "CertCommonName" to array-of-CHAR8. > > Locations where "CertCommonName" is used in the > CalculatePrivAuthVarSignChainSHA256Digest() function: > > - it is taken the size of -- not impacted by this patch; > > - passed to X509GetCommonName() as an argument -- the patch fixes the > build error; > > - passed to Sha256Update() as argument for "IN CONST VOID *Data" -- not > impacted by the patch; > > - passed to AsciiStrLen() as argument -- drop the now-superfluous explicit > cast. > > Since we are touching the Sha256Update() function call, fix the coding > style too: > > - the line is overlong, so break each argument to its own line; > > - insert a space between "AsciiStrLen" and the opening paren "(". > > Cc: Ard Biesheuvel > Cc: Chao Zhang > Cc: Gary Lin > Cc: Leif Lindholm > Cc: Long Qin > Reported-by: Gary Lin > Suggested-by: Gary Lin > Suggested-by: Long Qin > Fixes: 53c6ff18032737fabb644a9e0c781d91a6830248 > Contributed-under: TianoCore Contribution Agreement 1.1 > Signed-off-by: Laszlo Ersek > --- > > Notes: > The GCC build has been broken for too long by now; I'll push the patch > as soon as I get any Reviewed-by. > Reviewed-by: Ard Biesheuvel > SecurityPkg/Library/AuthVariableLib/AuthService.c | 8 ++++++-- > 1 file changed, 6 insertions(+), 2 deletions(-) > > diff --git a/SecurityPkg/Library/AuthVariableLib/AuthService.c b/SecurityPkg/Library/AuthVariableLib/AuthService.c > index 7188ff600823..2966811fa7ff 100644 > --- a/SecurityPkg/Library/AuthVariableLib/AuthService.c > +++ b/SecurityPkg/Library/AuthVariableLib/AuthService.c > @@ -1554,7 +1554,7 @@ CalculatePrivAuthVarSignChainSHA256Digest( > { > UINT8 *TbsCert; > UINTN TbsCertSize; > - UINT8 CertCommonName[128]; > + CHAR8 CertCommonName[128]; > UINTN CertCommonNameSize; > BOOLEAN CryptoStatus; > EFI_STATUS Status; > @@ -1590,7 +1590,11 @@ CalculatePrivAuthVarSignChainSHA256Digest( > // > // '\0' is forced in CertCommonName. No overflow issue > // > - CryptoStatus = Sha256Update (mHashCtx, CertCommonName, AsciiStrLen((CHAR8 *)CertCommonName)); > + CryptoStatus = Sha256Update ( > + mHashCtx, > + CertCommonName, > + AsciiStrLen (CertCommonName) > + ); > if (!CryptoStatus) { > return EFI_ABORTED; > } > -- > 2.14.1.3.gb7cf6e02401b >