aboutsummaryrefslogtreecommitdiffstats
path: root/common/homedir.c
diff options
context:
space:
mode:
authorWerner Koch <[email protected]>2024-01-26 08:41:00 +0000
committerWerner Koch <[email protected]>2024-01-26 08:41:00 +0000
commitdfa60c09f5cd992515df5fdb275dbee7f8f23b71 (patch)
treee68215d4b947727fa98eb8c95244b8819b058b1e /common/homedir.c
parentgpg: Clean up pk_ecdh_decrypt function. (diff)
parentPost release updates (diff)
downloadgnupg-dfa60c09f5cd992515df5fdb275dbee7f8f23b71.tar.gz
gnupg-dfa60c09f5cd992515df5fdb275dbee7f8f23b71.zip
Merge branch 'STABLE-BRANCH-2-4'
-- Fixed conflicts: NEWS configure.ac doc/gpg.texi
Diffstat (limited to 'common/homedir.c')
-rw-r--r--common/homedir.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/common/homedir.c b/common/homedir.c
index 2b99c9bdc..6f99f3eab 100644
--- a/common/homedir.c
+++ b/common/homedir.c
@@ -222,6 +222,10 @@ copy_dir_with_fixup (const char *newdir)
{
char *result = NULL;
char *p;
+#ifdef HAVE_W32_SYSTEM
+ char *p0;
+ const char *s;
+#endif
if (!*newdir)
return NULL;
@@ -253,6 +257,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] == '/')