Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into coverity_scan
Browse files Browse the repository at this point in the history
  • Loading branch information
AndreasFuchsTPM committed Feb 21, 2024
2 parents 770ef15 + 2db1d6b commit 292cff5
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 8 deletions.
2 changes: 1 addition & 1 deletion lib/pcr.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ static bool pcr_parse_list(const char *str, size_t len,
do {
char dgst_buf[sizeof(TPMU_HA) * 2 + 1];
const char *dgst;;
int dgst_len;
int dgst_len = 0;
UINT16 dgst_size;
int pcr_len;

Expand Down
4 changes: 3 additions & 1 deletion lib/tpm2_auth_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,12 +63,14 @@ static tool_rc get_auth_for_file_param(const char* password, TPM2B_AUTH *auth) {
const char* path = password;
size_t size = (sizeof(auth->buffer) * 2) + HEX_PREFIX_LEN + 2;
bool is_a_tty = isatty(STDIN_FILENO);
UINT8 *buffer = calloc(1, size);

/* Allocating one extra byte for \0 termination safety */
UINT8 *buffer = calloc(1, size + 1);
if (!buffer) {
LOG_ERR("oom");
return tool_rc_general_error;
}
buffer[size] = '\0';

if (path) {
path = strcmp("-", path) ? path : NULL;
Expand Down
1 change: 1 addition & 0 deletions lib/tpm2_openssl.c
Original file line number Diff line number Diff line change
Expand Up @@ -595,6 +595,7 @@ static bool load_public_RSA_from_key(EVP_PKEY *key, TPM2B_PUBLIC *pub) {
switch (rdetail->keyBits) {
case 1024: /* falls-through */
case 2048: /* falls-through */
case 3072: /* falls-through */
case 4096: /* falls-through */
break;
default:
Expand Down
4 changes: 2 additions & 2 deletions lib/tpm2_policy.c
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ static bool tpm2_apply_forward_seals(
unsigned int idx = 0;

if (pcr_selection->count != forwards->count) {
LOG_ERR("mismatch between pcr count (%d) and forward count (%lu)",
LOG_ERR("mismatch between pcr count (%d) and forward count (%zu)",
pcr_selection->count, forwards->count);

return false;
Expand Down Expand Up @@ -124,7 +124,7 @@ static bool tpm2_apply_forward_seals(
idx++;
if (idx == ARRAY_LEN(pcrs->pcr_values) *
ARRAY_LEN(pcrs->pcr_values[0].digests)) {
LOG_ERR("Too many PCRs specified (%u > %lu max)",
LOG_ERR("Too many PCRs specified (%u > %zu max)",
idx, ARRAY_LEN(pcrs->pcr_values) *
ARRAY_LEN(pcrs->pcr_values[0].digests));
}
Expand Down
6 changes: 3 additions & 3 deletions lib/tpm2_util.c
Original file line number Diff line number Diff line change
Expand Up @@ -635,9 +635,9 @@ char *tpm2_util_getenv(const char *name) {
bool tpm2_util_env_yes(const char *name) {

char *value = getenv(name);
return (value && (strcasecmp(name, "yes") == 0 ||
strcasecmp(name, "1") == 0 ||
strcasecmp(name, "true") == 0));
return (value && (strcasecmp(value, "yes") == 0 ||
strcasecmp(value, "1") == 0 ||
strcasecmp(value, "true") == 0));
}

/**
Expand Down
2 changes: 1 addition & 1 deletion man/tpm2_import.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ These options control the key importation process:

The algorithm used by the key to be imported. Supports:
* **aes** - AES 128, 192 or 256 key.
* **rsa** - RSA 1024 or 2048 key.
* **rsa** - RSA 1024, 2048, 3072, or 4096 key.
* **ecc** - ECC NIST P192, P224, P256, P384 or P521 public and private key.
* **hmac** - HMAC key.

Expand Down

0 comments on commit 292cff5

Please sign in to comment.