summaryrefslogtreecommitdiff
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 13:26:10 +0200
commitb7d1912cbb2b50add080fd1d7abee51d73ff3a53 (patch)
tree041270343ed64201587e6f14f287ebb8d084a314
parente2a4936eda39a6bb82703691f0ffa128e0d51415 (diff)
downloadrpm-b7d1912cbb2b50add080fd1d7abee51d73ff3a53.tar.gz
rpm-b7d1912cbb2b50add080fd1d7abee51d73ff3a53.tar.bz2
rpm-b7d1912cbb2b50add080fd1d7abee51d73ff3a53.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 (cherry picked from commit a46dd884ec348b3ce23b9f53302e6626a90ae631)
-rw-r--r--lib/rpmds.c32
1 files changed, 6 insertions, 26 deletions
diff --git a/lib/rpmds.c b/lib/rpmds.c
index 383c21f9e..75ff6fed6 100644
--- a/lib/rpmds.c
+++ b/lib/rpmds.c
@@ -44,6 +44,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)
{
@@ -81,28 +83,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;
@@ -268,8 +248,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;
@@ -304,8 +284,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;