diff options
author | Stefan Sperling <stsp@cvs.openbsd.org> | 2019-07-23 11:01:33 +0000 |
---|---|---|
committer | Stefan Sperling <stsp@cvs.openbsd.org> | 2019-07-23 11:01:33 +0000 |
commit | 02a754552fb99e26baabaae41e6cb2e184f0ca45 (patch) | |
tree | 6a4ed01b98667416305733ffeaa29ed45a1ac787 | |
parent | 49a8422db1d5d1ba7aa58b260fe133409042b3ed (diff) |
Fix realpath(3) errno code for an empty input path string.
It should return ENOENT in this case, but was returning EINVAL.
ok bluhm@ deraadt@
-rw-r--r-- | regress/sys/kern/realpath/realpathtest.c | 3 | ||||
-rw-r--r-- | sys/kern/vfs_syscalls.c | 6 |
2 files changed, 7 insertions, 2 deletions
diff --git a/regress/sys/kern/realpath/realpathtest.c b/regress/sys/kern/realpath/realpathtest.c index acd5a296918..01ce464b59e 100644 --- a/regress/sys/kern/realpath/realpathtest.c +++ b/regress/sys/kern/realpath/realpathtest.c @@ -1,4 +1,4 @@ -/* $OpenBSD: realpathtest.c,v 1.10 2019/07/15 16:05:04 bluhm Exp $ */ +/* $OpenBSD: realpathtest.c,v 1.11 2019/07/23 11:01:32 stsp Exp $ */ /* * Copyright (c) 2019 Bob Beck <beck@openbsd.org> @@ -101,6 +101,7 @@ main(int argc, char *argv[]) /* some basics */ RP_SHOULD_FAIL(NULL, NULL, NULL); + RP_SHOULD_FAIL("", NULL, NULL); RP_SHOULD_SUCCEED("/", NULL, NULL); RP_SHOULD_SUCCEED("/tmp", NULL, NULL); RP_SHOULD_FAIL("/tmp/noreallydoesntexist", NULL, NULL); diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 9a59d467756..0ab28d8481a 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.325 2019/07/22 16:43:10 anton Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.326 2019/07/23 11:01:32 stsp Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -890,6 +890,10 @@ sys___realpath(struct proc *p, void *v, register_t *retval) &pathlen))) goto end; + if (pathlen == 1) { /* empty string "" */ + error = ENOENT; + goto end; + } if (pathlen < 2) { error = EINVAL; goto end; |