Commit 7d515c1d731827fc8e2eb5cbf0043ffb5071c8bb

Authored by blueswir1
1 parent e4f5100c

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
Showing 1 changed file with 2 additions and 1 deletions
loader.c
@@ -90,11 +90,12 @@ int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f) @@ -90,11 +90,12 @@ int fread_targphys(target_phys_addr_t dst_addr, size_t nbytes, FILE *f)
90 while (nbytes) { 90 while (nbytes) {
91 want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes; 91 want = nbytes > sizeof(buf) ? sizeof(buf) : nbytes;
92 did = fread(buf, 1, want, f); 92 did = fread(buf, 1, want, f);
93 - if (did != want) break;  
94 93
95 cpu_physical_memory_write_rom(dst_addr, buf, did); 94 cpu_physical_memory_write_rom(dst_addr, buf, did);
96 dst_addr += did; 95 dst_addr += did;
97 nbytes -= did; 96 nbytes -= did;
  97 + if (did != want)
  98 + break;
98 } 99 }
99 return dst_addr - dst_begin; 100 return dst_addr - dst_begin;
100 } 101 }