mkrasimage: fix segmentation fault
authorMichael T Farnworth <[email protected]>
Sat, 22 Feb 2020 14:20:49 +0000 (14:20 +0000)
committerHauke Mehrtens <[email protected]>
Sun, 29 Mar 2020 16:47:32 +0000 (18:47 +0200)
commit96092a8eeadde1b868fb9b3345b361ed4e70c84d
treec7e52e260d8541e42055890d8b185d68a5adc738
parentbf5ea2a8dc8397f7b0dd975c06f9fc5dd04cb91b
mkrasimage: fix segmentation fault

Code was attempting to determine the size of the file
before it was actually known and allocating insufficient
memory space.  Images above a certain size caused a
segmentation fault.  Moving the calloc() ensured ensured
that large images didn't result in a buffer overflow on
memcpy().

Signed-off-by: Michael T Farnworth <[email protected]>
[fixed name in From to match one in SoB]
Signed-off-by: Petr Štetiar <[email protected]>
(cherry picked from commit b468353a373d181c4362ff690d7b22a08f5f6949)
tools/firmware-utils/src/mkrasimage.c