Commit 15c1467f authored by Fabio Utzig's avatar Fabio Utzig Committed by Fabio Utzig
Browse files

Return error from boot_find_key instead of asserting

When the hash key length parameter is invalid (bigger than allowed) just
return an error for the caller routines; this will work like a not found
key and allows the removal of assert() code in this module.

Signed-off-by: default avatarFabio Utzig <utzig@apache.org>
parent c962135f
Loading
Loading
Loading
Loading
+3 −2
Changes for boot/bootutil/src/image_validate.c: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
 * Modifications are Copyright (c) 2019 Arm Limited.
 */

#include <assert.h>
#include <stddef.h>
#include <inttypes.h>
#include <string.h>
@@ -183,7 +182,9 @@ bootutil_find_key(uint8_t *keyhash, uint8_t keyhash_len)
    const struct bootutil_key *key;
    uint8_t hash[32];

    assert(keyhash_len <= 32);
    if (keyhash_len > 32) {
        return -1;
    }

    for (i = 0; i < bootutil_key_cnt; i++) {
        key = &bootutil_keys[i];