diff options
| author | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2015-03-09 13:00:59 +0000 |
|---|---|---|
| committer | Edward Tomasz Napierala <trasz@FreeBSD.org> | 2015-03-09 13:00:59 +0000 |
| commit | 5585582d143cb0bc4cf45b14b7ec47629082e06b (patch) | |
| tree | 615c27b2d4364526969e676d416d3168e171fc84 /usr.sbin | |
| parent | 1bc6f4643817a0d7faed8795efa38e24bae1d51a (diff) | |
Notes
Diffstat (limited to 'usr.sbin')
| -rw-r--r-- | usr.sbin/autofs/common.c | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/usr.sbin/autofs/common.c b/usr.sbin/autofs/common.c index 8c455c40c268..0b4adc140807 100644 --- a/usr.sbin/autofs/common.c +++ b/usr.sbin/autofs/common.c @@ -136,8 +136,14 @@ separated_concat(const char *s1, const char *s2, char separator) assert(s1 != NULL); assert(s2 != NULL); - if (s1[0] == '\0' || s2[0] == '\0' || - s1[strlen(s1) - 1] == separator || s2[0] == separator) { + /* + * If s2 starts with separator - skip it; otherwise concatenating + * "/" and "/foo" would end up returning "//foo". + */ + if (s2[0] == separator) + s2++; + + if (s1[0] == '\0' || s2[0] == '\0' || s1[strlen(s1) - 1] == separator) { ret = asprintf(&result, "%s%s", s1, s2); } else { ret = asprintf(&result, "%s%c%s", s1, separator, s2); |
