Permalink
Browse files

Provides: Cast alpm_list contents to alpm_depend_t *

In libalpm 6, alpm_pkg_get_provides returns an alpm list containing pointers
to internal strings.

In libalpm 7, alpm_pkg_get_provides returns an alpm list containing pointers
to alpm_depend_t *

When powaur is building up trees for provides, this wrong casting to strings
causes us to write garbage into the trees instead of the package names,
resulting in a segfault when we search the provides trees during dependency
resolution.

This issue was originally reported by ato10 at:
#9

Signed-off-by: Pang Yan Han <pangyanhan@gmail.com>
  • Loading branch information...
1 parent d5dca5f commit 7ec04474a2f2de26ae20c71e09f9ca164d3f3786 @yanhan committed Jan 29, 2012
Showing with 3 additions and 1 deletion.
  1. +3 −1 hashdb.c
View
@@ -72,6 +72,7 @@ static void hash_packages(alpm_list_t *dbcache, struct hash_table *htable,
{
alpm_list_t *i, *k;
alpm_pkg_t *pkg;
+ alpm_depend_t *dep;
struct pkgpair pkgpair;
void *memlist_ptr;
@@ -90,7 +91,8 @@ static void hash_packages(alpm_list_t *dbcache, struct hash_table *htable,
/* Provides */
for (k = alpm_pkg_get_provides(pkg); k; k = k->next) {
- snprintf(buf, 1024, "%s", k->data);
+ dep = k->data;
+ snprintf(buf, 1024, "%s", dep->name);
if (!strtrim_ver(buf)) {
continue;
}

0 comments on commit 7ec0447

Please sign in to comment.