diff options
| author | Pali Rohár <[email protected]> | 2021-07-23 11:14:21 +0200 |
|---|---|---|
| committer | Stefan Roese <[email protected]> | 2021-07-31 09:49:32 +0200 |
| commit | 825a2ca023202f73a09660db7a49ac1109917ce8 (patch) | |
| tree | bccace9fd8fb11ffe27079df26f825a266fe618f /tools | |
| parent | b943eee915d79cbbaf7b4fc6c4c40dec4839380a (diff) | |
tools: kwboot: Check for v1 header size
Too small invalid headers may cause kwboot to crash.
Check for header size of v1 images.
Signed-off-by: Pali Rohár <[email protected]>
Reviewed-by: Marek Behún <[email protected]>
Reviewed-by: Stefan Roese <[email protected]>
Reviewed-by: Chris Packham <[email protected]>
Tested-by: Chris Packham <[email protected]>
Diffstat (limited to 'tools')
| -rw-r--r-- | tools/kwboot.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/tools/kwboot.c b/tools/kwboot.c index c0ac4ce19e9..1d32c1b7ad2 100644 --- a/tools/kwboot.c +++ b/tools/kwboot.c @@ -645,6 +645,11 @@ kwboot_img_patch_hdr(void *img, size_t size) else hdrsz = KWBHEADER_V1_SIZE(hdr); + if (size < hdrsz) { + errno = EINVAL; + goto out; + } + csum = kwboot_img_csum8(hdr, hdrsz) - hdr->checksum; if (csum != hdr->checksum) { errno = EINVAL; |
