aboutsummaryrefslogtreecommitdiffstats
path: root/iceprog
diff options
context:
space:
mode:
authorRoland Lutz <rlutz@hedmen.org>2017-06-08 19:40:08 +0200
committerRoland Lutz <rlutz@hedmen.org>2017-07-02 14:56:07 +0200
commit7b97eb41774019443f552ca1d49766b9798fee32 (patch)
treeb057a27c5f3227c9652f8c2c6bbc813696741d81 /iceprog
parent8413b2c68977b76cc17e01df299337d3f2aeba6f (diff)
downloadicestorm-7b97eb41774019443f552ca1d49766b9798fee32.tar.gz
icestorm-7b97eb41774019443f552ca1d49766b9798fee32.tar.bz2
icestorm-7b97eb41774019443f552ca1d49766b9798fee32.zip
iceprog: When reading, don't write more bytes than requested
Diffstat (limited to 'iceprog')
-rw-r--r--iceprog/iceprog.c3
1 files changed, 2 insertions, 1 deletions
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