From 7b97eb41774019443f552ca1d49766b9798fee32 Mon Sep 17 00:00:00 2001 From: Roland Lutz Date: Thu, 8 Jun 2017 19:40:08 +0200 Subject: iceprog: When reading, don't write more bytes than requested --- iceprog/iceprog.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'iceprog/iceprog.c') diff --git a/iceprog/iceprog.c b/iceprog/iceprog.c index e4e6f49..5233c46 100644 --- a/iceprog/iceprog.c +++ b/iceprog/iceprog.c @@ -742,7 +742,8 @@ int main(int argc, char **argv) for (int addr = 0; addr < read_size; addr += 256) { uint8_t buffer[256]; flash_read(rw_offset + addr, buffer, 256); - fwrite(buffer, 256, 1, f); + fwrite(buffer, read_size - addr > 256 ? 256 : + read_size - addr, 1, f); } } else -- cgit v1.2.3