[openssh-commits] [openssh] 04/07: upstream commit

git+noreply at mindrot.org git+noreply at mindrot.org
Wed Oct 14 08:29:13 AEDT 2015


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit c39ad23b06e9aecc3ff788e92f787a08472905b1
Author: Damien Miller <djm at mindrot.org>
Date:   Wed Oct 14 08:26:24 2015 +1100

    upstream commit
    
    revision 1.17
    date: 2014/10/18 20:43:52;  author: doug;  state: Exp;  lines: +10 -10;  commitid: I74hI1tVZtsspKEt;
    Better POSIX compliance in realpath(3).
    
    millert@ made changes to realpath.c based on FreeBSD's version.  I merged
    Todd's changes into dl_realpath.c.
    
    ok millert@, guenther@
---
 openbsd-compat/realpath.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/openbsd-compat/realpath.c b/openbsd-compat/realpath.c
index a954b1b..d2f34dd 100644
--- a/openbsd-compat/realpath.c
+++ b/openbsd-compat/realpath.c
@@ -1,4 +1,4 @@
-/*	$OpenBSD: realpath.c,v 1.16 2013/04/05 12:59:54 kurt Exp $ */
+/*	$OpenBSD: realpath.c,v 1.17 2014/10/18 20:43:52 doug Exp $ */
 /*
  * Copyright (c) 2003 Constantin S. Svintsoff <kostik at iclub.nsu.ru>
  *
@@ -62,6 +62,10 @@ realpath(const char *path, char *resolved)
 	int serrno, slen, mem_allocated;
 	char left[PATH_MAX], next_token[PATH_MAX], symlink[PATH_MAX];
 
+	if (path == NULL) {
+		errno = EINVAL;
+		return (NULL);
+	}
 	if (path[0] == '\0') {
 		errno = ENOENT;
 		return (NULL);
@@ -147,22 +151,15 @@ realpath(const char *path, char *resolved)
 		}
 
 		/*
-		 * Append the next path component and lstat() it. If
-		 * lstat() fails we still can return successfully if
-		 * there are no more path components left.
+		 * Append the next path component and lstat() it.
 		 */
 		resolved_len = strlcat(resolved, next_token, PATH_MAX);
 		if (resolved_len >= PATH_MAX) {
 			errno = ENAMETOOLONG;
 			goto err;
 		}
-		if (lstat(resolved, &sb) != 0) {
-			if (errno == ENOENT && p == NULL) {
-				errno = serrno;
-				return (resolved);
-			}
+		if (lstat(resolved, &sb) != 0)
 			goto err;
-		}
 		if (S_ISLNK(sb.st_mode)) {
 			if (symlinks++ > MAXSYMLINKS) {
 				errno = ELOOP;
@@ -205,6 +202,9 @@ realpath(const char *path, char *resolved)
 				}
 			}
 			left_len = strlcpy(left, symlink, sizeof(left));
+		} else if (!S_ISDIR(sb.st_mode) && p != NULL) {
+			errno = ENOTDIR;
+			goto err;
 		}
 	}
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list