summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNicolas Derumigny <nderumigny@gmail.com>2016-10-15 15:06:24 -0500
committerNicolas Derumigny <nderumigny@gmail.com>2016-10-15 15:06:24 -0500
commit976ef444b83d9c2ab1cff5cf95434d349e3c3161 (patch)
tree372796b6f37867fc3a777bac11f16fcf41037685 /src
parent6c72c3551978ef2eabbe9727bf24fd2fcf385318 (diff)
downloadgem5-976ef444b83d9c2ab1cff5cf95434d349e3c3161.tar.xz
syscall: read() should not write anything if reading EOF.
Read() should not write anything when returning 0 (EOF). This patch does not correct the same bug occuring for : nbr_read=read(file, buf, nbytes) When nbr_read<nbytes, nbytes bytes are copied into the virtual RAM instead of nbr_read. If buf is smaller than nbytes, a page fault occurs, even if buf is in fact bigger than nbr_read. Signed-off-by: Jason Lowe-Power <jason@lowepower.com>
Diffstat (limited to 'src')
-rw-r--r--src/sim/syscall_emul.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/sim/syscall_emul.cc b/src/sim/syscall_emul.cc
index 392658c5a..e62a8686a 100644
--- a/src/sim/syscall_emul.cc
+++ b/src/sim/syscall_emul.cc
@@ -245,7 +245,7 @@ readFunc(SyscallDesc *desc, int num, LiveProcess *p, ThreadContext *tc)
int bytes_read = read(sim_fd, bufArg.bufferPtr(), nbytes);
- if (bytes_read != -1)
+ if (bytes_read > 0)
bufArg.copyOut(tc->getMemProxy());
return bytes_read;