audk/SecurityPkg
Laszlo Ersek 11b74aa472 SecurityPkg/AuthVariableLib: fix GCC build error
Commit 53c6ff1803 ("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 <ard.biesheuvel@linaro.org>
Cc: Chao Zhang <chao.b.zhang@intel.com>
Cc: Gary Lin <glin@suse.com>
Cc: Leif Lindholm <leif.lindholm@linaro.org>
Cc: Long Qin <qin.long@intel.com>
Reported-by: Gary Lin <glin@suse.com>
Suggested-by: Gary Lin <glin@suse.com>
Suggested-by: Long Qin <qin.long@intel.com>
Fixes: 53c6ff1803
Contributed-under: TianoCore Contribution Agreement 1.1
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
Reviewed-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
Reviewed-by: Leif Lindholm <leif.lindholm@linaro.org>
2017-10-17 21:46:21 +02:00
..
Application/RngTest SecurityPkg: Add ARM/AARCH64 arch to enable RngTest module build. 2017-08-30 11:34:34 +08:00
Hash2DxeCrypto SecurityPkg: Fix typos in comments 2016-11-15 15:45:31 +08:00
Include SecurityPkg\Tcg2Pei: FV measure performance enhancement 2017-10-15 08:16:36 +08:00
Library SecurityPkg/AuthVariableLib: fix GCC build error 2017-10-17 21:46:21 +02:00
Pkcs7Verify/Pkcs7VerifyDxe Pkcs7VerifyDxe: Don't allow Pkcs7Verify to install protocols twice 2017-09-05 15:55:42 +08:00
RandomNumberGenerator/RngDxe
Tcg Security/OpalHii.c: Handle NULL Request or Request with no elements 2017-10-17 13:23:06 +08:00
UserIdentification SecurityPkg: Fix typos in comments 2016-11-15 16:21:33 +08:00
VariableAuthenticated SecurityPkg/SecureBootConfigDxe: Change the declaring of buffer. 2017-10-17 22:03:42 +08:00
SecurityPkg.dec SecurityPkg: make PcdOptionRomImageVerificationPolicy dynamic 2017-10-17 21:28:26 +02:00
SecurityPkg.dsc SecurityPkg: Add ARM/AARCH64 arch to enable RngTest module build. 2017-08-30 11:34:34 +08:00
SecurityPkg.uni SecurityPkg HashLibRouter: Avoid incorrect PcdTcg2HashAlgorithmBitmap 2017-02-08 18:52:07 +08:00
SecurityPkgExtra.uni