duskos

dusk os fork
git clone git://git.alexwennerberg.com/duskos
Log | Files | Refs | README | LICENSE

commit c3f856d32c507c1aa4d1c40403000f9a368f1dc2
parent 02d461c74f2d3c84343f48bc3a4d280397e0fd00
Author: Virgil Dupras <hsoft@hardcoded.net>
Date:   Sun, 20 Nov 2022 11:13:15 -0500

posix: add overlap guard in MOVE()

Dusk's kernel design doesn't require implementations of "move" to handle
overlapping memory address, so those are not supposed to happen. Because the
POSIX platform is a good test+debug platform, it's a good idea to warn about
them.

Diffstat:
Mposix/vm.c | 5+++++
1 file changed, 5 insertions(+), 0 deletions(-)

diff --git a/posix/vm.c b/posix/vm.c @@ -574,6 +574,11 @@ static void MOVE() { // op: 4c dword dst = ppop(); dword src = ppop(); if (memchk(dst+u) && memchk(src+u)) { + if ((dst >= src) && (dst < src+u)) { + fprintf(stderr, "overlapping MOVE! %x %x %d\n", src, dst, u); + ABORT_(); + return; + } memmove(&vm.mem[dst], &vm.mem[src], u); } }