From f8016646a9c26afbad95d7ae2f1e61e133264b78 Mon Sep 17 00:00:00 2001 From: dillon Date: Sun, 24 Jun 2001 05:24:41 +0000 Subject: After exhaustive discussions and some meandering and confusion, enough people are on track with the cause and effect of this, and although fixing this severely degenerate case appears to violate the letter of POSIX.1-200x, Bruce and I (and enough others) agree that it should be comitted. So, this patch generates an ENOENT error for any attempt to do a path lookup through an empty symlink (e.g. open(), stat()). Submitted by: "Andrey A. Chernov" Reviewed by: bde Discussed exhaustively on: freebsd-current Previously committed to: NetBSD 4 years ago --- sys/kern/vfs_lookup.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'sys/kern/vfs_lookup.c') diff --git a/sys/kern/vfs_lookup.c b/sys/kern/vfs_lookup.c index 0ad9d65..4875533 100644 --- a/sys/kern/vfs_lookup.c +++ b/sys/kern/vfs_lookup.c @@ -214,6 +214,12 @@ namei(ndp) break; } linklen = MAXPATHLEN - auio.uio_resid; + if (linklen == 0) { + if (ndp->ni_pathlen > 1) + zfree(namei_zone, cp); + error = ENOENT; + break; + } if (linklen + ndp->ni_pathlen >= MAXPATHLEN) { if (ndp->ni_pathlen > 1) zfree(namei_zone, cp); -- cgit v1.1