summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorPanu Matilainen <pmatilai@redhat.com>2011-11-30 11:00:40 +0200
committerPanu Matilainen <pmatilai@redhat.com>2011-11-30 11:00:40 +0200
commite83aa4f63817620633f5079064283cc9c3320e3f (patch)
tree842c488f1a35780094d6b180cf69cec15155a5fc /lib
parent52bcafcfb2e7c6bb8bb59f8def831e4f6a6f4930 (diff)
downloadlibrpm-tizen-e83aa4f63817620633f5079064283cc9c3320e3f.tar.gz
librpm-tizen-e83aa4f63817620633f5079064283cc9c3320e3f.tar.bz2
librpm-tizen-e83aa4f63817620633f5079064283cc9c3320e3f.zip
Update internal callers to use headerImport() instead of headerLoad()
- Pass size where possible, this is a bit redundant in places since its already checked in various places but wont hurt anyway.
Diffstat (limited to 'lib')
-rw-r--r--lib/header.c15
-rw-r--r--lib/package.c2
-rw-r--r--lib/rpmdb.c12
-rw-r--r--lib/signature.c7
4 files changed, 19 insertions, 17 deletions
diff --git a/lib/header.c b/lib/header.c
index 9ebf59222..403084bad 100644
--- a/lib/header.c
+++ b/lib/header.c
@@ -908,12 +908,13 @@ errxit:
Header headerReload(Header h, rpmTagVal tag)
{
Header nh;
- void * uh = doHeaderUnload(h, NULL);
+ size_t uc = 0;
+ void * uh = doHeaderUnload(h, &uc);
h = headerFree(h);
if (uh == NULL)
return NULL;
- nh = headerLoad(uh);
+ nh = headerImport(uh, uc, 0);
if (nh == NULL) {
uh = _free(uh);
return NULL;
@@ -943,7 +944,7 @@ Header headerRead(FD_t fd, int magicp)
int32_t il;
int32_t dl;
Header h = NULL;
- size_t len;
+ unsigned int len, blen;
if (magicp == HEADER_MAGIC_YES) {
int32_t magic;
@@ -966,7 +967,8 @@ Header headerRead(FD_t fd, int magicp)
dl = ntohl(block[1]);
}
- len = sizeof(il) + sizeof(dl) + (il * sizeof(struct entryInfo_s)) + dl;
+ blen = (il * sizeof(struct entryInfo_s)) + dl;
+ len = sizeof(il) + sizeof(dl) + blen;
/* Sanity checks on header intro. */
if (hdrchkTags(il) || hdrchkData(dl) || len > headerMaxbytes)
@@ -975,12 +977,11 @@ Header headerRead(FD_t fd, int magicp)
ei = xmalloc(len);
ei[0] = htonl(il);
ei[1] = htonl(dl);
- len -= sizeof(il) + sizeof(dl);
- if (Fread((char *)&ei[2], 1, len, fd) != len)
+ if (Fread((char *)&ei[2], 1, blen, fd) != blen)
goto exit;
- h = headerLoad(ei);
+ h = headerImport(ei, len, 0);
exit:
if (h == NULL && ei != NULL) {
diff --git a/lib/package.c b/lib/package.c
index 3df81c97a..1e44f4d8b 100644
--- a/lib/package.c
+++ b/lib/package.c
@@ -452,7 +452,7 @@ static rpmRC rpmpkgReadHeader(rpmKeyring keyring, rpmVSFlags vsflags,
goto exit;
/* OK, blob looks sane, load the header. */
- h = headerLoad(ei);
+ h = headerImport(ei, uc, 0);
if (h == NULL) {
free(buf);
rasprintf(&buf, _("hdr load: BAD\n"));
diff --git a/lib/rpmdb.c b/lib/rpmdb.c
index db0bd3206..6b0272a1b 100644
--- a/lib/rpmdb.c
+++ b/lib/rpmdb.c
@@ -1733,11 +1733,12 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
{
dbiIndex dbi;
void * uh;
- size_t uhlen;
+ unsigned int uhlen;
DBT key, data;
void * keyp;
size_t keylen;
int rc;
+ headerImportFlags importFlags = 0;
if (mi == NULL)
return NULL;
@@ -1746,6 +1747,9 @@ Header rpmdbNextIterator(rpmdbMatchIterator mi)
if (dbi == NULL)
return NULL;
+#if defined(_USE_COPY_LOAD)
+ importFlags |= HEADERIMPORT_COPY;
+#endif
/*
* Cursors are per-iterator, not per-dbi, so get a cursor for the
* iterator on 1st call. If the iteration is to rewrite headers, and the
@@ -1847,11 +1851,7 @@ top:
}
/* Did the header blob load correctly? */
-#if !defined(_USE_COPY_LOAD)
- mi->mi_h = headerLoad(uh);
-#else
- mi->mi_h = headerCopyLoad(uh);
-#endif
+ mi->mi_h = headerImport(uh, uhlen, importFlags);
if (mi->mi_h == NULL || !headerIsEntry(mi->mi_h, RPMTAG_NAME)) {
rpmlog(RPMLOG_ERR,
_("rpmdb: damaged header #%u retrieved -- skipping.\n"),
diff --git a/lib/signature.c b/lib/signature.c
index f5c80c984..63e59c00f 100644
--- a/lib/signature.c
+++ b/lib/signature.c
@@ -68,7 +68,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg)
int32_t dl;
int32_t * ei = NULL;
entryInfo pe;
- size_t nb;
+ unsigned int nb, uc;
int32_t ril = 0;
struct indexEntry_s entry;
struct entryInfo_s info;
@@ -112,7 +112,8 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg)
memset(&info, 0, sizeof(info));
nb = (il * sizeof(struct entryInfo_s)) + dl;
- ei = xmalloc(sizeof(il) + sizeof(dl) + nb);
+ uc = sizeof(il) + sizeof(dl) + nb;
+ ei = xmalloc(uc);
ei[0] = block[2];
ei[1] = block[3];
pe = (entryInfo) &ei[2];
@@ -194,7 +195,7 @@ rpmRC rpmReadSignature(FD_t fd, Header * sighp, sigType sig_type, char ** msg)
}
/* OK, blob looks sane, load the header. */
- sigh = headerLoad(ei);
+ sigh = headerImport(ei, uc, 0);
if (sigh == NULL) {
rasprintf(&buf, _("sigh load: BAD\n"));
goto exit;