Skip to content

Commit 0deb7f9

Browse files
JuergenReppSITAndreasFuchsTPM
authored andcommitted
tpm2_clockrateadjust: Fix segfault.
tpm2_clockrateadjust did produce a segfault if no rate adjust specifier was used. Fixes: #3494x Signed-off-by: Juergen Repp <juergen_repp@web.de>
1 parent b4bf516 commit 0deb7f9

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

tools/tpm2_clockrateadjust.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ struct tpm2_setclock_ctx {
3939
static tpm2_setclock_ctx ctx = {
4040
.auth_hierarchy.ctx_path = "o", /* default to owner hierarchy */
4141
.parameter_hash_algorithm = TPM2_ALG_ERROR,
42+
.adjustment = NULL,
4243
};
4344

4445

@@ -143,6 +144,11 @@ static tool_rc check_options(ESYS_CONTEXT *ectx) {
143144

144145
UNUSED(ectx);
145146

147+
if (!ctx.adjustment) {
148+
LOG_ERR("No clock rate adjust specifier is used");
149+
return tool_rc_option_error;
150+
}
151+
146152
size_t len = strlen(ctx.adjustment);
147153
if (len > 3) {
148154
LOG_ERR("Expected at most 3 adjustment characters");

0 commit comments

Comments
 (0)