X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=tools%2Fkwbimage.c;h=a88a3830c0c8d41c93765474622205f8b43c22d8;hb=0ddc510ea37aa578b8cb197840a5125409978bec;hp=ccecf8718537b04250a252adbf91f56ba6509772;hpb=39632b4a01210e329333d787d828157dcd2c7328;p=u-boot diff --git a/tools/kwbimage.c b/tools/kwbimage.c index ccecf87185..a88a3830c0 100644 --- a/tools/kwbimage.c +++ b/tools/kwbimage.c @@ -1,3 +1,4 @@ +// SPDX-License-Identifier: GPL-2.0+ /* * Image manipulator for Marvell SoCs * supports Kirkwood, Dove, Armada 370, Armada XP, and Armada 38x @@ -5,8 +6,6 @@ * (C) Copyright 2013 Thomas Petazzoni * * - * SPDX-License-Identifier: GPL-2.0+ - * * Not implemented: support for the register headers in v1 images */ @@ -24,7 +23,8 @@ #include #include -#if OPENSSL_VERSION_NUMBER < 0x10100000L || defined(LIBRESSL_VERSION_NUMBER) +#if OPENSSL_VERSION_NUMBER < 0x10100000L || \ + (defined(LIBRESSL_VERSION_NUMBER) && LIBRESSL_VERSION_NUMBER < 0x2070000fL) static void RSA_get0_key(const RSA *r, const BIGNUM **n, const BIGNUM **e, const BIGNUM **d) { @@ -36,7 +36,7 @@ static void RSA_get0_key(const RSA *r, *d = r->d; } -#else +#elif !defined(LIBRESSL_VERSION_NUMBER) void EVP_MD_CTX_cleanup(EVP_MD_CTX *ctx) { EVP_MD_CTX_reset(ctx); @@ -1615,6 +1615,10 @@ static int kwbimage_verify_header(unsigned char *ptr, int image_size, struct image_tool_params *params) { uint8_t checksum; + size_t header_size = kwbimage_header_size(ptr); + + if (header_size > image_size) + return -FDT_ERR_BADSTRUCTURE; if (!main_hdr_checksum_ok(ptr)) return -FDT_ERR_BADSTRUCTURE;