Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAndrew Gregory <andrew.gregory.8@gmail.com>2013-02-13 17:49:02 -0500
committerAllan McRae <allan@archlinux.org>2013-02-16 11:06:43 +1000
commitbc747fbfbf22bdf5bcf3e2b016afdd21bdea6068 (patch)
treeae75705e192763beb14b51c0a7d615fe94cd9009 /lib
parentd5a5a6b512f20cf0b6f72e58ca0479af69044359 (diff)
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.c12
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);