fix: make getcwd report truncated buffers as ERANGE
This commit is contained in:
@@ -2286,8 +2286,9 @@ char *getcwd(char *buf, size_t size) {
|
||||
errno = EINVAL;
|
||||
return NULL;
|
||||
}
|
||||
if ((int)_zos_syscall2(SYS_GETCWD, (long)buf, (long)size) < 0) {
|
||||
errno = ERANGE;
|
||||
int result = (int)_zos_syscall2(SYS_GETCWD, (long)buf, (long)size);
|
||||
if (result < 0) {
|
||||
errno = result == -2 ? ERANGE : EIO;
|
||||
return NULL;
|
||||
}
|
||||
return buf;
|
||||
|
||||
Binary file not shown.
@@ -64,7 +64,9 @@
|
||||
int montauk::chdir(const char* path);
|
||||
|
||||
.B SYS_GETCWD (95)
|
||||
Get the calling process's current working directory.
|
||||
Get the calling process's current working directory. Returns the path
|
||||
length on success, -2 if maxLen cannot hold the path and terminating NUL,
|
||||
or -1 for another failure. The buffer is not modified when it is too small.
|
||||
int montauk::getcwd(char* buf, uint64_t maxLen);
|
||||
|
||||
.B SYS_SETUSER (92)
|
||||
|
||||
Reference in New Issue
Block a user