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;
int32_t il;
int32_t dl;
Header h = NULL;
- size_t len;
+ unsigned int len, blen;
if (magicp == HEADER_MAGIC_YES) {
int32_t magic;
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)
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) {
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"));
{
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;
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
}
/* 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"),
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;
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];
}
/* 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;