diff options
author | Lucas Dietrich <ld.adecy@gmail.com> | 2025-07-07 17:55:50 +0200 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2025-07-14 15:16:45 -0600 |
commit | 6a269b7fdefe3edc60a6218f1402f17206644628 (patch) | |
tree | 3611e5f3396708a3952a51c8ad28239d2c614ed9 /lib/ecdsa/ecdsa-libcrypto.c | |
parent | 41713b99671f6775c18d70d31ccd8b27e438abe1 (diff) |
ecdsa: fix segfault in mkimage when "-r" option is not set
Fix a segmentation fault in the ECDSA signing logic of `mkimage`
that occurs when the "-r" option is not specified.
This reproduces the logic in `lib/rsa/rsa-sign.c` by checking if
`info->require_keys` is non-null before passing it to
`fdt_setprop_string()`.
Signed-off-by: Lucas Dietrich <lucas.dietrich.git@proton.me>
Diffstat (limited to 'lib/ecdsa/ecdsa-libcrypto.c')
-rw-r--r-- | lib/ecdsa/ecdsa-libcrypto.c | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/ecdsa/ecdsa-libcrypto.c b/lib/ecdsa/ecdsa-libcrypto.c index 7415d685ee1..c4bfb2cec61 100644 --- a/lib/ecdsa/ecdsa-libcrypto.c +++ b/lib/ecdsa/ecdsa-libcrypto.c @@ -519,10 +519,12 @@ static int do_add(struct signer *ctx, void *fdt, const char *key_node_name, if (ret < 0) return ret; - ret = fdt_setprop_string(fdt, key_node, FIT_KEY_REQUIRED, - info->require_keys); - if (ret < 0) - return ret; + if (info->require_keys) { + ret = fdt_setprop_string(fdt, key_node, FIT_KEY_REQUIRED, + info->require_keys); + if (ret < 0) + return ret; + } return key_node; } |