]> 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/branches/nano_2_0_branch/nano@4074 35c25a1d-7b9e-4130-9fde-d3aeb78583b8

ChangeLog
src/files.c

index 26bba3b6b4d2a0ae3e8a62b56cfc041498697504..b3dd79158e05a74fdc4daeca84b407b16b317e65 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -4,6 +4,11 @@ CVS code -
        - Fix segfault when dealing with directory names that begin with
          "~", but that aren't users' home directories. (DLR, found by
          Justin Fletcher)
+       - 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)
 - doc/syntax/asm.nanorc, doc/syntax/c.nanorc, doc/syntax/sh.nanorc:
        - Copy the regex that highlights trailing whitespace from
          doc/syntax/java.nanorc to these files, as it's also useful in
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;