commit 94a805a20b2fabc6a3194a24e92e2a68c85c7cb3
parent 51b259439cdf0eb201532949cd381cbd35743594
Author: Michael Schierl <schierlm@gmx.de>
Date: Sat, 19 Nov 2022 22:41:47 +0100
POSIX VM: Make invalid paths work on Cygwin
When running tests on cygwin, tests fail, because
p" lib/nope.fs"
can find a valid path object.
When performing the FCHILD op, the POSIX VM first calls realpath on the
path, then validates if it has seen the path before, and if not it calls
stat on the result to check whether it exists.
However, the return value of realpath was not checked.
While on Linux, realpath returns success and fills the buffer with the
same path again, on Cygwin realpath returns ENOENT and leaves the buffer
empty. And it seems that the POSIX VM has seen an empty path before...
This fix makes test pass on POSIX VM for me.
Diffstat:
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/posix/vm.c b/posix/vm.c
@@ -809,7 +809,7 @@ static char* pathcat(char *p1, dword s) {
strcpy(buf1, p1);
strcat(buf1, "/");
strncat(buf1, (char*)&vm.mem[s], len);
- realpath(buf1, buf2);
+ if (!realpath(buf1, buf2)) return "/NoSuchFile";
return buf2;
}