From 2c53bb4eb5196fa041e91b7f07c985021f90bf79 Mon Sep 17 00:00:00 2001 From: Norbert Warmuth Date: Wed, 28 Apr 1999 04:03:30 +0000 Subject: [PATCH] Tue Apr 27 20:31:13 1999 Norbert Warmuth * src/util.c (strip_home_and_password): Don't split the path in the middle of a directory, e.g. "/home/bofh" will not be translated to "~h" (fixes the bug reported by Alex Fortuna ) --- src/ChangeLog | 6 ++++++ src/util.c | 4 +++- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/ChangeLog b/src/ChangeLog index 10a09e905..dd46f7263 100644 --- a/src/ChangeLog +++ b/src/ChangeLog @@ -1,3 +1,9 @@ +Tue Apr 27 20:31:13 1999 Norbert Warmuth + + * util.c (strip_home_and_password): Don't split the path in the + middle of a directory, e.g. "/home/bofh" will not be translated to + "~h" (fixes the bug reported by Alex Fortuna ) + 1999-04-25 Sergei Ivanov * find.c: The origin of the bug is in the function do_search (file diff --git a/src/util.c b/src/util.c index 902c542c5..c0cb334c9 100644 --- a/src/util.c +++ b/src/util.c @@ -384,9 +384,11 @@ strip_password (char *p, int has_prefix) char *strip_home_and_password(char *dir) { + size_t len; static char newdir [MC_MAXPATHLEN]; - if (home_dir && !strncmp (dir, home_dir, strlen (home_dir))){ + if (home_dir && !strncmp (dir, home_dir, len = strlen (home_dir)) && + (dir[len] == PATH_SEP || dir[len] == '\0')){ newdir [0] = '~'; strcpy (&newdir [1], &dir [strlen (home_dir)]); return newdir;