diff --git a/ChangeLog b/ChangeLog index a40c11d2..f6dbc3ee 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2007-04-17 David Lawrence Ramsey + + * 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 * files.c (real_dir_from_tilde): Fix segfault when dealing with 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;