Skip to content

Commit

Permalink
lib: just copy the TPMU_HA union instead of copying its member
Browse files Browse the repository at this point in the history
The TPMU_HA is just a union data type, so instead of attempting to copy
.na field, copy the union since both refer to the same memory location.

This also allows the tpm2-tools to be built against the tpm2-tss 1.x
since the TPMU_HA union doesn't have a .na field in that version. So it
prevents the following build error:

lib/tpm2_alg_util.c: In function ‘tpm2_extract_plain_signature’:
lib/tpm2_alg_util.c:348:33: error: ‘TPMU_HA {aka union <anonymous>}’ has no member named ‘na’
         memcpy(buffer, &hmac_sig->na, *size);
                                 ^~
make: *** [Makefile:1871: lib/tpm2_alg_util.o] Error 1

Signed-off-by: Javier Martinez Canillas <javierm@redhat.com>
  • Loading branch information
martinezjavier authored and William Roberts committed Nov 13, 2017
1 parent 60f235d commit 8e7c52b
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/tpm2_alg_util.c
Expand Up @@ -351,7 +351,7 @@ UINT8* tpm2_extract_plain_signature(UINT16 *size, TPMT_SIGNATURE *signature) {
if (!buffer) {
goto nomem;
}
memcpy(buffer, &hmac_sig->na, *size);
memcpy(buffer, &hmac_sig, *size);
break;
}
case TPM_ALG_ECDSA: {
Expand Down

0 comments on commit 8e7c52b

Please sign in to comment.