]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/tpm2-tools/0001-tpm2_certify-fix-type-may-be-used-uninitialized-warn.patch
tpm2-tools: fix compilation error due to uninitialized variable
[coffee/buildroot.git] / package / tpm2-tools / 0001-tpm2_certify-fix-type-may-be-used-uninitialized-warn.patch
1 From e15b01a1eb27e31964308892fcaa9c7d4f17f181 Mon Sep 17 00:00:00 2001
2 From: Carlos Santos <casantos@datacom.ind.br>
3 Date: Sat, 24 Mar 2018 22:46:46 -0300
4 Subject: [PATCH] tpm2_certify: fix "'type' may be used uninitialized" warning
5
6 get_key_type does not assign a value to 'type' on error conditions,
7 which makes the compiler believe that it will be used uninitialized in
8 the LOG_ERR call, in set_scheme. In practice this will never happen
9 because set_scheme returns immediately if get_key_type retuns false but
10 the compiler does not understand that logic and fails because warnings
11 are treated as errors.
12
13 Adapted for version 3.0.3 from the change submitted upstream:
14
15   https://github.com/tpm2-software/tpm2-tools/pull/954
16
17 Signed-off-by: Carlos Santos <casantos@datacom.ind.br>
18 ---
19  tools/tpm2_certify.c | 1 +
20  1 file changed, 1 insertion(+)
21
22 diff --git a/tools/tpm2_certify.c b/tools/tpm2_certify.c
23 index eaac02f..cbc42a9 100644
24 --- a/tools/tpm2_certify.c
25 +++ b/tools/tpm2_certify.c
26 @@ -107,6 +107,7 @@ static bool get_key_type(TSS2_SYS_CONTEXT *sapi_context, TPMI_DH_OBJECT object_h
27              &out_public, &name, &qualified_name, &sessions_data_out));
28      if (rval != TPM_RC_SUCCESS) {
29          LOG_ERR("TPM2_ReadPublic failed. Error Code: 0x%x", rval);
30 +        *type = TPM_ALG_ERROR;
31          return false;
32      }
33  
34 -- 
35 2.14.3
36