From: Dan Streetman Date: Mon, 21 Aug 2023 21:29:28 +0000 (-0400) Subject: tpm2: put !isempty() check inside previous !isempty() check X-Git-Tag: v255-rc1~630^2~14 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=2b2ee3f265957e4dda9f82b1b6e8138117a90502;p=thirdparty%2Fsystemd.git tpm2: put !isempty() check inside previous !isempty() check --- diff --git a/src/shared/tpm2-util.c b/src/shared/tpm2-util.c index 794474776b0..4b368728646 100644 --- a/src/shared/tpm2-util.c +++ b/src/shared/tpm2-util.c @@ -1730,23 +1730,23 @@ int tpm2_pcr_value_from_string(const char *arg, Tpm2PCRValue *ret_pcr_value) { if (r < 0) return log_error_errno(r, "Invalid pcr hash algorithm '%s': %m", hash); pcr_value.hash = (TPMI_ALG_HASH) r; - } - if (!isempty(p)) { - /* Remove leading 0x if present */ - p = startswith_no_case(p, "0x") ?: p; + if (!isempty(p)) { + /* Remove leading 0x if present */ + p = startswith_no_case(p, "0x") ?: p; - _cleanup_free_ void *buf = NULL; - size_t buf_size = 0; - r = unhexmem(p, SIZE_MAX, &buf, &buf_size); - if (r < 0) - return log_error_errno(r, "Invalid pcr hash value '%s': %m", p); + _cleanup_free_ void *buf = NULL; + size_t buf_size = 0; + r = unhexmem(p, SIZE_MAX, &buf, &buf_size); + if (r < 0) + return log_error_errno(r, "Invalid pcr hash value '%s': %m", p); - r = TPM2B_DIGEST_CHECK_SIZE(buf_size); - if (r < 0) - return log_error_errno(r, "PCR hash value size %zu too large.", buf_size); + r = TPM2B_DIGEST_CHECK_SIZE(buf_size); + if (r < 0) + return log_error_errno(r, "PCR hash value size %zu too large.", buf_size); - pcr_value.value = TPM2B_DIGEST_MAKE(buf, buf_size); + pcr_value.value = TPM2B_DIGEST_MAKE(buf, buf_size); + } } *ret_pcr_value = pcr_value;