1
0
mirror of git://git.gnupg.org/gnupg.git synced 2024-12-22 10:19:57 +01:00

Avoid a leading double slash in make_filename.

* common/stringhelp.c (do_make_filename): Special case leading '/'.
This commit is contained in:
Werner Koch 2015-07-22 11:05:32 +02:00
parent 9901be3956
commit 69d2c9b09b
No known key found for this signature in database
GPG Key ID: E3FDFF218E45B72B

View File

@ -493,7 +493,13 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
xfree (home_buffer);
for (argc=0; argv[argc]; argc++)
p = stpcpy (stpcpy (p, "/"), argv[argc]);
{
/* Avoid a leading double slash if the first part was "/". */
if (!argc && name[0] == '/' && !name[1])
p = stpcpy (p, argv[argc]);
else
p = stpcpy (stpcpy (p, "/"), argv[argc]);
}
if (want_abs)
{
@ -543,7 +549,13 @@ do_make_filename (int xmode, const char *first_part, va_list arg_ptr)
memcpy (home_buffer, p, p - name + 1);
p = home_buffer + (p - name + 1);
}
strcpy (stpcpy (stpcpy (p, home), "/"), name);
/* Avoid a leading double slash if the cwd is "/". */
if (home[0] == '/' && !home[1])
strcpy (stpcpy (p, "/"), name);
else
strcpy (stpcpy (stpcpy (p, home), "/"), name);
xfree (name);
name = home_buffer;
/* Let's do a simple compression to catch the most common