mirror of
https://github.com/clearlinux/swupd-client.git
synced 2026-09-08 14:42:02 +00:00
sys: Also remove trailing separators in sys_path_join()
Always remove the last slash of a path when using sys_path_join().
This is needed because some functions compare different paths and the
trailing slash will lead to incorrect results.
For example:
- sys_path_is_absolute(sys_path_join("/usr/")) returns false.
Signed-off-by: Otavio Pontes <otavio.pontes@intel.com>
This commit is contained in:
+2
-1
@@ -445,7 +445,8 @@ char *sys_path_join(const char *fmt, ...)
|
||||
|
||||
/* remove all duplicated PATH_SEPARATOR from the path */
|
||||
for (i = j = 0; i < len; i++) {
|
||||
if (path[i] == PATH_SEPARATOR && path[i + 1] == PATH_SEPARATOR) {
|
||||
if (path[i] == PATH_SEPARATOR &&
|
||||
(path[i + 1] == PATH_SEPARATOR || path[i + 1] == '\0')) {
|
||||
/* duplicated PATH_SEPARATOR, throw it away */
|
||||
continue;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user