diff options
author | Andrew Gregory <andrew.gregory.8@gmail.com> | 2013-02-13 17:49:02 -0500 |
---|---|---|
committer | Allan McRae <allan@archlinux.org> | 2013-02-16 11:06:43 +1000 |
commit | bc747fbfbf22bdf5bcf3e2b016afdd21bdea6068 (patch) | |
tree | ae75705e192763beb14b51c0a7d615fe94cd9009 /lib | |
parent | d5a5a6b512f20cf0b6f72e58ca0479af69044359 (diff) | |
download | pacman-bc747fbfbf22bdf5bcf3e2b016afdd21bdea6068.tar.xz |
fix off-by-one error in _alpm_filelist_resolve
'/' should not be appended to the resolved root when root is "/".
Signed-off-by: Andrew Gregory <andrew.gregory.8@gmail.com>
Signed-off-by: Allan McRae <allan@archlinux.org>
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); |