lib/tpm2_eventlog_yaml.c: fix buffer overflow in bytes_to_str()
lib/tpm2_eventlog_yaml.c: fix buffer overflow in bytes_to_str()

The output buffer dest should usually have an odd length (two characters per
byte in hexadecimal representation, plus one for the null terminator). If the
buffer had an even dest_size <= 2*size, the null terminator was written out of
bounds to dest[dest_size]. Ensure that the null terminator is stored within the
array bounds by omitting the last byte from the hex representation if
necessary.

This issue was triggered by the recent commit
46942ef1731f36ca862067130c211854368aef67, leading to the compiler warning/error

In function ‘bytes_to_str’,
    inlined from ‘yaml_sha1_log_eventhdr_callback’ at lib/tpm2_eventlog_yaml.c:344:5:
lib/tpm2_eventlog_yaml.c:90:13: error: writing 1 byte into a region of size 0 [-Werror=stringop-overflow=]
   90 |     dest[j] = '\0';
      |     ~~~~~~~~^~~~~~
lib/tpm2_eventlog_yaml.c: In function ‘yaml_sha1_log_eventhdr_callback’:
lib/tpm2_eventlog_yaml.c:343:10: note: at offset 40 to object ‘hexstr’ with size 40 declared here
  343 |     char hexstr[20 * 2] = { 0, };
      |          ^~~~~~
cc1: all warnings being treated as errors

Fix this instance by using the existing macro BYTES_TO_HEX_STRING_SIZE to
calculate the correct buffer length.

Signed-off-by: Jonas Witschel <87a164e5d00d5dcdd001e37b34ea8bcd3fc3a172@gmx.de>

01org/tpm2.0-tools,01org/tpm2.0-tools,01org/tpm2.0-tools