summaryrefslogtreecommitdiff
path: root/lib/rpmds.c
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2009-01-20 12:55:35 +0200
committerPanu Matilainen <pmatilai@redhat.com>2009-01-20 12:55:35 +0200
commita46dd884ec348b3ce23b9f53302e6626a90ae631 (patch)
tree3cf99d155388b1086ac5eaa61a54426a8af6917b /lib/rpmds.c
parent6bd713ab319514d655d0466330a246703a7c16ae (diff)
downloadlibrpm-tizen-a46dd884ec348b3ce23b9f53302e6626a90ae631.tar.gz
librpm-tizen-a46dd884ec348b3ce23b9f53302e6626a90ae631.tar.bz2
librpm-tizen-a46dd884ec348b3ce23b9f53302e6626a90ae631.zip
rpmdsMerge() expects ds->N and ds->EVR as argv-style arrays (ticket #22)
- use rpmdsDupArgv() instead of cloning headerGet() behavior to fix this for rpmdsSingle() and rpmdsThis() generated dependency sets - this is a regression from rpm 4.4.x, but for rpmdsNew() created sets rpmdsMerge() has never worked as headerGet() doesn't return NULL terminated arrays
Diffstat (limited to 'lib/rpmds.c')
-rw-r--r--lib/rpmds.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index f102884a1..45b43bc69 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -43,6 +43,8 @@ struct rpmds_s {
int nrefs; /*!< Reference count. */
};
+static const char ** rpmdsDupArgv(const char ** argv, int argc);
+
static int dsType(rpmTag tag,
const char ** Type, rpmTag * tagEVR, rpmTag * tagF)
{
@@ -80,28 +82,6 @@ static int dsType(rpmTag tag,
return rc;
}
-/*
- * Dupe a string into string array (of size 1) + contents stored in a single
- * allocation block similarly to how header data is returned so it will
- * be freed by single free().
- */
-static const char ** str2hge(const char *str)
-{
- const char ** arr;
- size_t slen = str ? strlen(str) + 1 : 0;
- char *t = xmalloc(sizeof(*arr) + slen);
- arr = (const char **) t;
-
- if (str) {
- t += sizeof(*arr);
- strcpy(t, str);
- } else {
- t = NULL;
- }
- arr[0] = t;
- return arr;
-}
-
rpmds rpmdsUnlink(rpmds ds, const char * msg)
{
if (ds == NULL) return NULL;
@@ -263,8 +243,8 @@ rpmds rpmdsThis(Header h, rpmTag tagN, rpmsenseFlags Flags)
ds->tagN = tagN;
ds->Count = 1;
ds->nopromote = _rpmds_nopromote;
- ds->N = str2hge(n);
- ds->EVR = str2hge(evr);
+ ds->N = rpmdsDupArgv(&n, 1);
+ ds->EVR = rpmdsDupArgv((const char **)&evr, 1);
free(evr);
ds->Flags = xmalloc(sizeof(*ds->Flags)); ds->Flags[0] = Flags;
@@ -298,8 +278,8 @@ rpmds rpmdsSingle(rpmTag tagN, const char * N, const char * EVR, rpmsenseFlags F
ds->Count = 1;
ds->nopromote = _rpmds_nopromote;
- ds->N = str2hge(N);
- ds->EVR = str2hge(EVR);
+ ds->N = rpmdsDupArgv(&N, 1);
+ ds->EVR = rpmdsDupArgv(&EVR, 1);
ds->Flags = xmalloc(sizeof(*ds->Flags));
ds->Flags[0] = Flags;