diff options
author | Werner Koch <[email protected]> | 2024-01-09 09:09:36 +0000 |
---|---|---|
committer | Werner Koch <[email protected]> | 2024-01-09 09:09:45 +0000 |
commit | cc9568cd59b2d3944d34c601e7c8cf9ea462a245 (patch) | |
tree | 17ce496cecf9897bc9384273a2d70c5ca0136d15 | |
parent | Post release updates (diff) | |
download | gnupg-cc9568cd59b2d3944d34c601e7c8cf9ea462a245.tar.gz gnupg-cc9568cd59b2d3944d34c601e7c8cf9ea462a245.zip |
common,w32: Remove duplicated backslashes when setting the homedir.
* common/homedir.c (copy_dir_with_fixup) [W32]: Fold double
backslashes.
--
This is in general no problem but when we hash or compare the directory
to test whether tit is the standard home directory, we may use a
different socket file and thus a second instance of a daemon.
GnuPG-bug-id: 6833
-rw-r--r-- | NEWS | 5 | ||||
-rw-r--r-- | common/homedir.c | 26 |
2 files changed, 29 insertions, 2 deletions
@@ -1,6 +1,9 @@ -Noteworthy changes in version 2.2.42 (unreleased) +Noteworthy changes in version 2.2.43 (unreleased) ------------------------------------------------- + * dirmngr: Avoid starting a second instance on Windows via GPGME + based launching. [T6833] + Noteworthy changes in version 2.2.42 (2023-11-28) ------------------------------------------------- diff --git a/common/homedir.c b/common/homedir.c index 9788c22f1..fb2640d67 100644 --- a/common/homedir.c +++ b/common/homedir.c @@ -176,7 +176,8 @@ static char * copy_dir_with_fixup (const char *newdir) { char *result = NULL; - char *p; + char *p, *p0; + const char *s; if (!*newdir) return NULL; @@ -208,6 +209,29 @@ copy_dir_with_fixup (const char *newdir) *p-- = 0; } + /* Hack to mitigate badly doubled backslashes. */ + s = result? result : newdir; + if (s[0] == '\\' && s[1] == '\\' && s[2] != '\\') + { + /* UNC (\\Servername\file) or Long UNC (\\?\Servername\file) + * Does not seem to be double quoted. */ + } + else if (strstr (s, "\\\\")) + { + /* Double quotes detected. Fold them into one because that is + * what what Windows does. This way we get a unique hash + * regardless of the number of doubled backslashes. */ + if (!result) + result = xstrdup (newdir); + for (p0=p=result; *p; p++) + { + *p0++ = *p; + while (*p == '\\' && p[1] == '\\') + p++; + } + *p0 = 0; + } + #else /*!HAVE_W32_SYSTEM*/ if (newdir[strlen (newdir)-1] == '/') |