Skip to content
Snippets Groups Projects
Commit abe19f63 authored by Mark Tomlinson's avatar Mark Tomlinson Committed by Troy Kisky
Browse files

tools: mkimage: Ensure munmap unmaps the same length that was mapped


The set_header call in kwbimage.c adds a checksum to the end of the
image in addition to setting up the header. It 'helpfully' updates the
st_size to match the fact that the file is now longer. However, mkimage
uses this length in the munmap call. This can lead to unmapping an extra
page, of perhaps required data. When this happens, a SEGV can occur.

To prevent this from happening, the munmap call now uses the same length
that was passed to mmap. This could also have been fixed by not changing
the length in kwbimage.c, however changing it in the main file means
that other plugins will also not fall for the same trap.

Signed-off-by: default avatarMark Tomlinson <mark.tomlinson@alliedtelesis.co.nz>
Signed-off-by: default avatarChris Packham <judge.packham@gmail.com>
[cp: resolve checkpatch complaints]
Tested-by: default avatarChris Packham <judge.packham@gmail.com>
parent 65a566ee
No related branches found
No related tags found
No related merge requests found
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment