]> git.wh0rd.org Git - nano.git/commitdiff
in real_dir_from_tilde(), fix long-standing problem where directory
authorDavid Lawrence Ramsey <pooka109@gmail.com>
Tue, 17 Apr 2007 04:38:30 +0000 (04:38 +0000)
committerDavid Lawrence Ramsey <pooka109@gmail.com>
Tue, 17 Apr 2007 04:38:30 +0000 (04:38 +0000)
names that began with "~", but that weren't users' home directories,
could be erroneously treated as users' home directories (e.g. "~d/"
would be treated as "~daemon/")

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@4074 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index a40c11d2d2489937b2511268bebee4c68a4eee46..f6dbc3eec9246b85f9758f5081cbabf515b55550 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2007-04-17  David Lawrence Ramsey  <pooka109@gmail.com>
+
+       * files.c (real_dir_from_tilde): Fix long-standing problem where
+       directory names that began with "~", but that weren't users'
+       home directories, could be erroneously treated as users' home
+       directories (e.g. "~d/" would be treated as "~daemon/"). (DLR,
+       found by Justin Fletcher)
+
 2007-04-16  David Lawrence Ramsey  <pooka109@gmail.com>
 
        * files.c (real_dir_from_tilde): Fix segfault when dealing with
index 68d760e63945138e203229c888586d2f0d9e311d..bde29e1178999acae76b44b0ed1bc3f3b51009b0 100644 (file)
@@ -1995,7 +1995,8 @@ char *real_dir_from_tilde(const char *buf)
            do {
                userdata = getpwent();
            } while (userdata != NULL &&
-               strncmp(userdata->pw_name, buf + 1, i - 1) != 0);
+               (strncmp(userdata->pw_name, buf + 1, i - 1) != 0 ||
+               strlen(userdata->pw_name) != strnlen(buf + 1, i - 1)));
            endpwent();
            if (userdata != NULL)
                tilde_dir = userdata->pw_dir;