diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/libalpm/filelist.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c index f29bb7c4..c4814a49 100644 --- a/lib/libalpm/filelist.c +++ b/lib/libalpm/filelist.c @@ -198,12 +198,16 @@ int _alpm_filelist_resolve(alpm_handle_t *handle, alpm_filelist_t *files) if(realpath(handle->root, path) == NULL){ return -1; } - root_len = strlen(path) + 1; - if(root_len >= PATH_MAX) { + root_len = strlen(path); + if(root_len + 1 >= PATH_MAX) { return -1; } - path[root_len - 1] = '/'; - path[root_len] = '\0'; + /* append '/' if root is not "/" */ + if(path[root_len - 1] != '/') { + path[root_len] = '/'; + root_len++; + path[root_len] = '\0'; + } ret = _alpm_filelist_resolve_link(files, &i, path, root_len, 0); |