From 2ebdcd94aa54e60a6abdbc523d1bea52ad6bb2c4 Mon Sep 17 00:00:00 2001 From: David Lawrence Ramsey Date: Tue, 17 Apr 2007 04:38:30 +0000 Subject: [PATCH] in 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/") git-svn-id: svn://svn.savannah.gnu.org/nano/branches/nano_2_0_branch/nano@4074 35c25a1d-7b9e-4130-9fde-d3aeb78583b8 --- ChangeLog | 5 +++++ src/files.c | 3 ++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/ChangeLog b/ChangeLog index 26bba3b6..b3dd7915 100644 --- 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 diff --git a/src/files.c b/src/files.c index 68d760e6..bde29e11 100644 --- a/src/files.c +++ b/src/files.c @@ -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; -- 2.39.5