From: Michael Schroeder Date: Mon, 30 Jan 2017 15:18:46 +0000 (+0100) Subject: Guard against dirpool_add_dir being called with an illegal component id X-Git-Tag: 0.6.25~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=3a8f2216aeec9126968ea3d99872f839548a6d65;p=thirdparty%2Flibsolv.git Guard against dirpool_add_dir being called with an illegal component id --- diff --git a/src/dirpool.c b/src/dirpool.c index 5f083616..fc57cc5c 100644 --- a/src/dirpool.c +++ b/src/dirpool.c @@ -99,8 +99,10 @@ dirpool_make_dirtraverse(Dirpool *dp) Id dirpool_add_dir(Dirpool *dp, Id parent, Id comp, int create) { - Id did, d, ds, *dirtraverse; + Id did, d, ds; + if (comp <= 0) + return 0; if (!dp->ndirs) { if (!create) @@ -116,8 +118,7 @@ dirpool_add_dir(Dirpool *dp, Id parent, Id comp, int create) dirpool_make_dirtraverse(dp); /* check all entries with this parent if we * already have this component */ - dirtraverse = dp->dirtraverse; - ds = dirtraverse[parent]; + ds = dp->dirtraverse[parent]; while (ds) { /* ds: first component in this block diff --git a/src/repo_write.c b/src/repo_write.c index 210636c4..396cd427 100644 --- a/src/repo_write.c +++ b/src/repo_write.c @@ -955,6 +955,10 @@ traverse_dirs(Dirpool *dp, Id *dirmap, Id n, Id dir, Id *used) dirmap[n++] = sib; } + /* check if our block has some content */ + if (parent == n) + return n - 1; /* nope, drop parent id again */ + /* now go through all the siblings we just added and * do recursive calls on them */ lastn = n;