While such paths should not be included internally, we cannot
guarantee that external scripts with shebangs will not do this.
Some older versions of plymouth also resulted in double /'s
in some paths, so best deal with this gracefully.
size_t length;
/* Strip the basename and any redundant slashes before it. */
for (length = strlen(file); 0 < length; length--)
- if (file[length] == '/')
+ if (file[length] == '/' && file[length-1] != '/')
break;
return length;
}
return strdup(from);
}
- asprintf(&realtarget, "%s/%s", q, &p[dirlen + 1]);
+ /* dir_len() skips double /'s e.g. //lib64, so we can't skip just one
+ * character - need to skip all leading /'s */
+ rl = strlen(target);
+ for (i = dirlen+1; i < rl; ++i)
+ if (p[i] != '/')
+ break;
+ asprintf(&realtarget, "%s/%s", q, &p[i]);
free(p);
free(q);