]> www.infradead.org Git - mtd-utils.git/commit
misc-utils: flashcp: fix buffer overflow
authorBrandon Maier <brandon.maier@collins.com>
Wed, 2 Nov 2022 22:47:55 +0000 (17:47 -0500)
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>
Mon, 7 Nov 2022 07:24:42 +0000 (08:24 +0100)
commit92d826ac57e753da120a82cded354931b3fe8e76
tree200a63e08ed29dc633e0f06247801955ebcdd0b2
parent345c5bde41fc1238a3f3b9b1a52e30ec7ab99b6e
misc-utils: flashcp: fix buffer overflow

The DIFF_BLOCKS code requires that src and dest buffers be large enough
to hold one MTD erasesize. This is because each loop operates on one
eraseblock so that it can erase and write one whole sector. But the src
and dest buffers are fixed at BUFSIZE, so on platforms where the MTD
erasesize are larger then BUFSIZE it will overflow the buffers.

Instead allocate the buffers dynamically so that they can be sized to
fit the erasesize.

Signed-off-by: Brandon Maier <brandon.maier@collins.com>
Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
misc-utils/flashcp.c