aboutsummaryrefslogtreecommitdiff
path: root/loader.c
diff options
context:
space:
mode:
authorblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-09 18:08:56 +0000
committerblueswir1 <blueswir1@c046a42c-6fe2-441c-8c8c-71466251a162>2009-03-09 18:08:56 +0000
commit7d515c1d731827fc8e2eb5cbf0043ffb5071c8bb (patch)
tree33c858b12384a82ab510b66591ea10ed336a481e /loader.c
parente4f5100c33fdb6dcc3d3b5af52798ea79adc472d (diff)
downloadqemu-7d515c1d731827fc8e2eb5cbf0043ffb5071c8bb.zip
qemu-7d515c1d731827fc8e2eb5cbf0043ffb5071c8bb.tar.gz
qemu-7d515c1d731827fc8e2eb5cbf0043ffb5071c8bb.tar.bz2
fread_targphys(): Do not cut off the tail.
loader.c:fread_targphys() read file by 4096 byte chunks and store them to memory. But did not store the last chunk if its size was not 4096. Signed-off-by: Takashi YOSHII <takasi-y@ops.dti.ne.jp> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6792 c046a42c-6fe2-441c-8c8c-71466251a162
Diffstat (limited to 'loader.c')
-rw-r--r--loader.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/loader.c b/loader.c
index 71b9ba7..55625cf 100644
--- a/loader.c
+++ b/loader.c
@@ -90,11 +90,12 @@ int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)
while (nbytes) {
want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;
did = fread(buf, 1, want, f);
- if (did != want) break;
cpu_physical_memory_write_rom(dst_addr, buf, did);
dst_addr += did;
nbytes -= did;
+ if (did != want)
+ break;
}
return dst_addr - dst_begin;
}