Send patches - preferably formatted by git format-patch - to patches at archlinux32 dot org.
summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAllan McRae <allan@archlinux.org>2012-12-06 22:35:22 +1000
committerAllan McRae <allan@archlinux.org>2012-12-14 12:35:34 +1000
commit0c2edbdd4992f3107d7a2bd600829fcb3f344d48 (patch)
treef58f6bf0007535b9f992fa341affa4705e063758 /lib
parent4a427dbc1bca50c516c41e4ae2cb0122c686f88d (diff)
It turns out we do care about directories...
This is a bug that has been around since at least 2007. On a package upgrade (either by -S or -U) a new directory could overwrite any file. This is caused by the filelist difference calculation ignoring all directories and thus no new directories were checked for conflicting files on the filesystem. Signed-off-by: Allan McRae <allan@archlinux.org>
Diffstat (limited to 'lib')
-rw-r--r--lib/libalpm/filelist.c28
1 files changed, 9 insertions, 19 deletions
diff --git a/lib/libalpm/filelist.c b/lib/libalpm/filelist.c
index bf7645b8..f884e6a8 100644
--- a/lib/libalpm/filelist.c
+++ b/lib/libalpm/filelist.c
@@ -228,34 +228,24 @@ alpm_list_t *_alpm_filelist_difference(alpm_filelist_t *filesA,
alpm_file_t *fileA = filesA->files + ctrA;
const char *strA = filesA->resolved_path[ctrA];
const char *strB = filesB->resolved_path[ctrB];
- /* skip directories, we don't care about them */
- if(strA[strlen(strA)-1] == '/') {
+
+ int cmp = strcmp(strA, strB);
+ if(cmp < 0) {
+ /* item only in filesA, qualifies as a difference */
+ ret = alpm_list_add(ret, fileA);
ctrA++;
- } else if(strB[strlen(strB)-1] == '/') {
+ } else if(cmp > 0) {
ctrB++;
} else {
- int cmp = strcmp(strA, strB);
- if(cmp < 0) {
- /* item only in filesA, qualifies as a difference */
- ret = alpm_list_add(ret, fileA);
- ctrA++;
- } else if(cmp > 0) {
- ctrB++;
- } else {
- ctrA++;
- ctrB++;
- }
+ ctrA++;
+ ctrB++;
}
}
/* ensure we have completely emptied pA */
while(ctrA < filesA->count) {
alpm_file_t *fileA = filesA->files + ctrA;
- const char *strA = fileA->name;
- /* skip directories */
- if(strA[strlen(strA)-1] != '/') {
- ret = alpm_list_add(ret, fileA);
- }
+ ret = alpm_list_add(ret, fileA);
ctrA++;
}