rpmfi.c   rpmfi.c 
/** \ingroup rpmfi /** \ingroup rpmfi
* \file lib/rpmfi.c * \file lib/rpmfi.c
* Routines to handle file info tag sets. * Routines to handle file info tag sets.
*/ */
#include "system.h" #include "system.h"
#include <rpmio.h>
#include <rpmiotypes.h> /* XXX fnpyKey */ #include <rpmiotypes.h> /* XXX fnpyKey */
#include <rpmio.h>
#include <rpmlog.h> #include <rpmlog.h>
#include <rpmbf.h> #include <rpmbf.h>
#include <rpmurl.h> /* XXX urlGetPath */ #include <rpmurl.h> /* XXX urlGetPath */
#define _RPMDIR_INTERNAL #define _RPMDIR_INTERNAL
#include <rpmdir.h> #include <rpmdir.h>
#include <rpmmacro.h> /* XXX rpmCleanPath */ #include <rpmmacro.h> /* XXX rpmCleanPath */
#include <ugid.h> #include <ugid.h>
#define _RPMAV_INTERNAL /* XXX avOpendir */ #define _RPMAV_INTERNAL /* XXX avOpendir */
#include <rpmdav.h> #include <rpmdav.h>
skipping to change at line 50 skipping to change at line 50
#include "debug.h" #include "debug.h"
/*@access IOSM_t @*/ /* XXX cast */ /*@access IOSM_t @*/ /* XXX cast */
/*@access rpmte @*/ /*@access rpmte @*/
/*@access rpmts @*/ /* XXX cast */ /*@access rpmts @*/ /* XXX cast */
/*@access FSM_t @*/ /* XXX fsm->repackaged */ /*@access FSM_t @*/ /* XXX fsm->repackaged */
/*@access DIR @*/ /*@access DIR @*/
#ifdef __cplusplus
GENfree(int *)
GENpair(rpmuint16_t *)
GENpair(rpmuint32_t *)
GENfree(rpmRelocation)
#endif /* __cplusplus */
/** /**
*/ */
struct rpmRelocation_s { struct rpmRelocation_s {
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
const char * oldPath; /*!< NULL here evals to RPMTAG_DEFAULTPREFIX , */ const char * oldPath; /*!< NULL here evals to RPMTAG_DEFAULTPREFIX , */
/*@only@*/ /*@null@*/ /*@only@*/ /*@null@*/
const char * newPath; /*!< NULL means to omit the file completely! */ const char * newPath; /*!< NULL means to omit the file completely! */
}; };
/*@unchecked@*/ /*@unchecked@*/
skipping to change at line 164 skipping to change at line 171
} }
const char * rpmfiFN(rpmfi fi) const char * rpmfiFN(rpmfi fi)
{ {
const char * FN = ""; const char * FN = "";
if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) { if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) {
const char *dn; const char *dn;
char * t; char * t;
if (fi->fn == NULL) if (fi->fn == NULL)
fi->fn = xmalloc(fi->fnlen + 1); fi->fn = (char *) xmalloc(fi->fnlen + 1);
FN = t = fi->fn; FN = t = fi->fn;
(void) urlPath(fi->dnl[fi->dil[fi->i]], &dn); (void) urlPath(fi->dnl[fi->dil[fi->i]], &dn);
*t = '\0'; *t = '\0';
t = stpcpy(t, dn); t = stpcpy(t, dn);
t = stpcpy(t, fi->bnl[fi->i]); t = stpcpy(t, fi->bnl[fi->i]);
} }
return FN; return FN;
} }
void * rpmfiFNBF(rpmfi fi) void * rpmfiFNBF(rpmfi fi)
{ {
void * _fnbf = NULL; void * _fnbf = NULL;
if (fi != NULL) { if (fi != NULL) {
if (fi->_fnbf == NULL) { if (fi->_fnbf == NULL) {
char * fn = alloca(fi->fnlen + 1); char * fn = (char *) alloca(fi->fnlen + 1);
static double e = 1.0e-4; static double e = 1.0e-4;
size_t n = (fi->fc > 10 ? fi->fc : 10); size_t n = (fi->fc > 10 ? fi->fc : 10);
size_t m = 0; size_t m = 0;
size_t k = 0; size_t k = 0;
rpmbf bf; rpmbf bf;
int i; int i;
rpmbfParams(n, e, &m, &k); rpmbfParams(n, e, &m, &k);
bf = rpmbfNew(m, k, 0); bf = rpmbfNew(m, k, 0);
for (i = 0; i < (int)fi->fc; i++) { for (i = 0; i < (int)fi->fc; i++) {
skipping to change at line 271 skipping to change at line 278
if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) { if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) {
if (fi->fmodes != NULL) if (fi->fmodes != NULL)
fmode = fi->fmodes[fi->i]; fmode = fi->fmodes[fi->i];
} }
return fmode; return fmode;
} }
rpmfileState rpmfiFState(rpmfi fi) rpmfileState rpmfiFState(rpmfi fi)
{ {
rpmfileState fstate = RPMFILE_STATE_MISSING; rpmfileState fstate = (rpmfileState) RPMFILE_STATE_MISSING;
if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) { if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) {
if (fi->fstates != NULL) if (fi->fstates != NULL)
fstate = fi->fstates[fi->i]; fstate = (rpmfileState) fi->fstates[fi->i];
} }
return fstate; return fstate;
} }
rpmfileState rpmfiSetFState(rpmfi fi, rpmfileState fstate) rpmfileState rpmfiSetFState(rpmfi fi, rpmfileState fstate)
{ {
rpmuint32_t ofstate = 0; rpmuint32_t ofstate = 0;
if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) { if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) {
if (fi->fstates != NULL) { if (fi->fstates != NULL) {
ofstate = fi->fstates[fi->i]; ofstate = fi->fstates[fi->i];
fi->fstates[fi->i] = fstate; fi->fstates[fi->i] = fstate;
} }
} }
return ofstate; return (rpmfileState) ofstate;
} }
const unsigned char * rpmfiDigest(rpmfi fi, int * algop, size_t * lenp) const unsigned char * rpmfiDigest(rpmfi fi, int * algop, size_t * lenp)
{ {
unsigned char * digest = NULL; unsigned char * digest = NULL;
if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) { if (fi != NULL && fi->i >= 0 && fi->i < (int)fi->fc) {
if (fi->digests != NULL) { if (fi->digests != NULL) {
digest = fi->digests + (fi->digestlen * fi->i); digest = fi->digests + (fi->digestlen * fi->i);
if (algop != NULL) if (algop != NULL)
skipping to change at line 514 skipping to change at line 521
struct fingerPrint_s * fps = NULL; struct fingerPrint_s * fps = NULL;
if (fi != NULL && fi->fps != NULL && ix >= 0 && ix < (int)fi->fc) { if (fi != NULL && fi->fps != NULL && ix >= 0 && ix < (int)fi->fc) {
fps = fi->fps + ix; fps = fi->fps + ix;
} }
return fps; return fps;
} }
void rpmfiFpLookup(rpmfi fi, fingerPrintCache fpc) void rpmfiFpLookup(rpmfi fi, fingerPrintCache fpc)
{ {
if (fi->fc > 0 && fi->fps == NULL) { if (fi->fc > 0 && fi->fps == NULL) {
fi->fps = xcalloc(fi->fc, sizeof(*fi->fps)); fi->fps = (struct fingerPrint_s *) xcalloc(fi->fc, sizeof(*fi->fps)) ;
} }
fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps); fpLookupList(fpc, fi->dnl, fi->bnl, fi->dil, fi->fc, fi->fps);
} }
int rpmfiNext(rpmfi fi) int rpmfiNext(rpmfi fi)
{ {
int i = -1; int i = -1;
if (fi != NULL && ++fi->i >= 0) { if (fi != NULL && ++fi->i >= 0) {
if (fi->i < (int)fi->fc) { if (fi->i < (int)fi->fc) {
skipping to change at line 762 skipping to change at line 769
* the ones in the two packages are different. It would * the ones in the two packages are different. It would
* be nice if RPM was smart enough to at least try and * be nice if RPM was smart enough to at least try and
* merge the difference ala CVS, but... * merge the difference ala CVS, but...
*/ */
return save; return save;
} }
/*@observer@*/ /*@observer@*/
const char * rpmfiTypeString(rpmfi fi) const char * rpmfiTypeString(rpmfi fi)
{ {
switch(rpmteType(fi->te)) { switch(rpmteType((rpmte)fi->te)) {
case TR_ADDED: return " install"; case TR_ADDED: return " install";
case TR_REMOVED: return " erase"; case TR_REMOVED: return " erase";
default: return "???"; default: return "???";
} }
/*@noteached@*/ /*@noteached@*/
} }
#define alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) #define alloca_strdup(_s) strcpy((char *)alloca(strlen(_s)+1), (_s))
/** /**
* Relocate files in header. * Relocate files in header.
* @todo multilib file dispositions need to be checked. * @todo multilib file dispositions need to be checked.
* @param ts transaction set * @param ts transaction set
* @param fi transaction element file info * @param fi transaction element file info
* @param origH package header * @param origH package header
* @param actions file dispositions * @param actions file dispositions
* @return header with relocated files * @return header with relocated files
*/ */
static static
Header relocateFileList(const rpmts ts, rpmfi fi, Header relocateFileList(const rpmts ts, rpmfi fi,
Header origH, iosmFileAction * actions) Header origH, iosmFileAction * actions)
/*@globals rpmGlobalMacroContext, h_errno, /*@globals rpmGlobalMacroContext, h_errno,
internalState @*/ internalState @*/
/*@modifies ts, fi, origH, actions, rpmGlobalMacroContext, /*@modifies ts, fi, origH, actions, rpmGlobalMacroContext,
internalState @*/ internalState @*/
{ {
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he));
rpmte p = rpmtsRelocateElement(ts); rpmte p = rpmtsRelocateElement(ts);
static int _printed = 0; static int _printed = 0;
int allowBadRelocate = (rpmtsFilterFlags(ts) & RPMPROB_FILTER_FORCERELO CATE); int allowBadRelocate = (rpmtsFilterFlags(ts) & RPMPROB_FILTER_FORCERELO CATE);
rpmRelocation relocations = NULL; rpmRelocation relocations = NULL;
int numRelocations; int numRelocations;
const char ** validRelocations; const char ** validRelocations;
rpmTagType validType; rpmTagType validType;
int numValid; int numValid;
const char ** baseNames; const char ** baseNames;
const char ** dirNames; const char ** dirNames;
skipping to change at line 860 skipping to change at line 867
/* XXX FIXME multilib file actions need to be checked. */ /* XXX FIXME multilib file actions need to be checked. */
/*@-castexpose@*/ /*@-castexpose@*/
return headerLink(origH); return headerLink(origH);
/*@=castexpose@*/ /*@=castexpose@*/
} }
/*@-castexpose@*/ /*@-castexpose@*/
h = headerLink(origH); h = headerLink(origH);
/*@=castexpose@*/ /*@=castexpose@*/
relocations = alloca(sizeof(*relocations) * numRelocations); relocations = (rpmRelocation) alloca(sizeof(*relocations) * numRelocati ons);
/* Build sorted relocation list from raw relocations. */ /* Build sorted relocation list from raw relocations. */
for (i = 0; i < numRelocations; i++) { for (i = 0; i < numRelocations; i++) {
char * t; char * t;
/* /*
* Default relocations (oldPath == NULL) are handled in the UI, * Default relocations (oldPath == NULL) are handled in the UI,
* not rpmlib. * not rpmlib.
*/ */
if (p->relocs[i].oldPath == NULL) continue; /* XXX can't happen */ if (p->relocs[i].oldPath == NULL) continue; /* XXX can't happen */
skipping to change at line 953 skipping to change at line 960
rpmlog(RPMLOG_DEBUG, D_("%5d relocate %s -> %s\n"), rpmlog(RPMLOG_DEBUG, D_("%5d relocate %s -> %s\n"),
i, relocations[i].oldPath, relocations[i].newPath); i, relocations[i].oldPath, relocations[i].newPath);
} }
} }
/* Add relocation values to the header */ /* Add relocation values to the header */
if (numValid) { if (numValid) {
const char ** actualRelocations; const char ** actualRelocations;
int numActual; int numActual;
actualRelocations = xmalloc(numValid * sizeof(*actualRelocations)); actualRelocations = (const char **) xmalloc(numValid * sizeof(*actua lRelocations));
numActual = 0; numActual = 0;
for (i = 0; i < numValid; i++) { for (i = 0; i < numValid; i++) {
for (j = 0; j < numRelocations; j++) { for (j = 0; j < numRelocations; j++) {
if (relocations[j].oldPath == NULL || /* XXX can't happen */ if (relocations[j].oldPath == NULL || /* XXX can't happen */
strcmp(validRelocations[i], relocations[j].oldPath)) strcmp(validRelocations[i], relocations[j].oldPath))
/*@innercontinue@*/ continue; /*@innercontinue@*/ continue;
/* On install, a relocate to NULL means skip the path. */ /* On install, a relocate to NULL means skip the path. */
if (relocations[j].newPath) { if (relocations[j].newPath) {
actualRelocations[numActual] = relocations[j].newPath; actualRelocations[numActual] = relocations[j].newPath;
numActual++; numActual++;
skipping to change at line 1006 skipping to change at line 1013
he->tag = RPMTAG_FILEFLAGS; he->tag = RPMTAG_FILEFLAGS;
xx = headerGet(h, he, 0); xx = headerGet(h, he, 0);
fFlags = he->p.ui32p; fFlags = he->p.ui32p;
he->tag = RPMTAG_FILECOLORS; he->tag = RPMTAG_FILECOLORS;
xx = headerGet(h, he, 0); xx = headerGet(h, he, 0);
fColors = he->p.ui32p; fColors = he->p.ui32p;
he->tag = RPMTAG_FILEMODES; he->tag = RPMTAG_FILEMODES;
xx = headerGet(h, he, 0); xx = headerGet(h, he, 0);
fModes = he->p.ui16p; fModes = he->p.ui16p;
dColors = alloca(dirCount * sizeof(*dColors)); dColors = (rpmuint32_t *) alloca(dirCount * sizeof(*dColors));
memset(dColors, 0, dirCount * sizeof(*dColors)); memset(dColors, 0, dirCount * sizeof(*dColors));
/* /*
* For all relocations, we go through sorted file/relocation lists * For all relocations, we go through sorted file/relocation lists
* backwards so that /usr/local relocations take precedence over /usr * backwards so that /usr/local relocations take precedence over /usr
* ones. * ones.
*/ */
/* Relocate individual paths. */ /* Relocate individual paths. */
for (i = fileCount - 1; i >= 0; i--) { for (i = fileCount - 1; i >= 0; i--) {
rpmFileTypes ft; rpmFileTypes ft;
size_t fnlen; size_t fnlen;
len = reldel + len = reldel +
strlen(dirNames[dirIndexes[i]]) + strlen(baseNames[i]) + 1; strlen(dirNames[dirIndexes[i]]) + strlen(baseNames[i]) + 1;
if (len >= fileAlloced) { if (len >= fileAlloced) {
fileAlloced = len * 2; fileAlloced = len * 2;
fn = xrealloc(fn, fileAlloced); fn = (char *) xrealloc(fn, fileAlloced);
} }
assert(fn != NULL); /* XXX can't happen */ assert(fn != NULL); /* XXX can't happen */
*fn = '\0'; *fn = '\0';
fnlen = stpcpy( stpcpy(fn, dirNames[dirIndexes[i]]), baseNames[i]) - fn; fnlen = stpcpy( stpcpy(fn, dirNames[dirIndexes[i]]), baseNames[i]) - fn;
if (fColors != NULL) { if (fColors != NULL) {
/* XXX pkgs may not have unique dirNames, so color all dirNames that match. */ /* XXX pkgs may not have unique dirNames, so color all dirNames that match. */
for (j = 0; j < (int)dirCount; j++) { for (j = 0; j < (int)dirCount; j++) {
if (strcmp(dirNames[dirIndexes[i]], dirNames[j])) /*@innercontinue@*/ conti nue; if (strcmp(dirNames[dirIndexes[i]], dirNames[j])) /*@innercontinue@*/ conti nue;
skipping to change at line 1136 skipping to change at line 1143
if (j < (int)dirCount) { if (j < (int)dirCount) {
dirIndexes[i] = j; dirIndexes[i] = j;
continue; continue;
} }
/* Creating new paths is a pita */ /* Creating new paths is a pita */
if (!haveRelocatedFile) { if (!haveRelocatedFile) {
const char ** newDirList; const char ** newDirList;
haveRelocatedFile = 1; haveRelocatedFile = 1;
newDirList = xmalloc((dirCount + 1) * sizeof(*newDirList)); newDirList = (const char **) xmalloc((dirCount + 1) * sizeof(*ne wDirList));
for (j = 0; j < (int)dirCount; j++) for (j = 0; j < (int)dirCount; j++)
newDirList[j] = alloca_strdup(dirNames[j]); newDirList[j] = alloca_strdup(dirNames[j]);
dirNames = _free(dirNames); dirNames = _free(dirNames);
dirNames = newDirList; dirNames = newDirList;
} else { } else {
dirNames = xrealloc(dirNames, dirNames = (const char **) xrealloc(dirNames,
sizeof(*dirNames) * (dirCount + 1)); sizeof(*dirNames) * (dirCount + 1));
} }
dirNames[dirCount] = alloca_strdup(fn); dirNames[dirCount] = alloca_strdup(fn);
dirIndexes[i] = dirCount; dirIndexes[i] = dirCount;
dirCount++; dirCount++;
} }
/* Finish off by relocating directories. */ /* Finish off by relocating directories. */
for (i = dirCount - 1; i >= 0; i--) { for (i = dirCount - 1; i >= 0; i--) {
skipping to change at line 1178 skipping to change at line 1185
/* /*
* Only subdirectories or complete file paths may be relocated. We * Only subdirectories or complete file paths may be relocated. We
* don't check for '\0' as our directory names all end in '/'. * don't check for '\0' as our directory names all end in '/'.
*/ */
if (dirNames[i][len] != '/') if (dirNames[i][len] != '/')
/*@innercontinue@*/ continue; /*@innercontinue@*/ continue;
if (relocations[j].newPath) { /* Relocate the path */ if (relocations[j].newPath) { /* Relocate the path */
const char * s = relocations[j].newPath; const char * s = relocations[j].newPath;
char * t = alloca(strlen(s) + strlen(dirNames[i]) - len + 1) size_t slen = strlen(s) + strlen(dirNames[i]) - len;
; char * t = (char *) alloca(slen + 1);
size_t slen;
(void) stpcpy( stpcpy(t, s) , dirNames[i] + len); (void) stpcpy( stpcpy(t, s) , dirNames[i] + len);
/* Unfortunatly rpmCleanPath strips the trailing slash.. */ /* Unfortunatly rpmCleanPath strips the trailing slash.. */
(void) rpmCleanPath(t); (void) rpmCleanPath(t);
slen = strlen(t); slen = strlen(t);
t[slen] = '/'; t[slen] = '/';
t[slen+1] = '\0'; t[slen+1] = '\0';
if (actions) if (actions)
skipping to change at line 1283 skipping to change at line 1290
/*@-assignexpose -castexpose @*/ /*@-assignexpose -castexpose @*/
if (h != NULL) if (h != NULL)
fi->h = headerLink(h); fi->h = headerLink(h);
/*@=assignexpose =castexpose @*/ /*@=assignexpose =castexpose @*/
return 0; return 0;
} }
static void rpmfiFini(void * _fi) static void rpmfiFini(void * _fi)
/*@modifies *_fi @*/ /*@modifies *_fi @*/
{ {
rpmfi fi = _fi; rpmfi fi = (rpmfi) _fi;
/* Free pre- and post-transaction script and interpreter strings. */ /* Free pre- and post-transaction script and interpreter strings. */
fi->pretrans = _free(fi->pretrans); fi->pretrans = _free(fi->pretrans);
fi->pretransprog = _free(fi->pretransprog); fi->pretransprog = _free(fi->pretransprog);
fi->posttrans = _free(fi->posttrans); fi->posttrans = _free(fi->posttrans);
fi->posttransprog = _free(fi->posttransprog); fi->posttransprog = _free(fi->posttransprog);
fi->verifyscript = _free(fi->verifyscript); fi->verifyscript = _free(fi->verifyscript);
fi->verifyscriptprog = _free(fi->verifyscriptprog); fi->verifyscriptprog = _free(fi->verifyscriptprog);
if (fi->fc > 0) { if (fi->fc > 0) {
skipping to change at line 1326 skipping to change at line 1333
fi->dil = _free(fi->dil); fi->dil = _free(fi->dil);
fi->fcolors = _free(fi->fcolors); fi->fcolors = _free(fi->fcolors);
fi->fcdictx = _free(fi->fcdictx); fi->fcdictx = _free(fi->fcdictx);
fi->ddict = _free(fi->ddict); fi->ddict = _free(fi->ddict);
fi->fddictx = _free(fi->fddictx); fi->fddictx = _free(fi->fddictx);
fi->fddictn = _free(fi->fddictn); fi->fddictn = _free(fi->fddictn);
} }
/*@-globs@*/ /* Avoid rpmGlobalMacroContext */ /*@-globs@*/ /* Avoid rpmGlobalMacroContext */
fi->fsm = freeFSM(fi->fsm); fi->fsm = freeFSM((IOSM_t)fi->fsm);
/*@=globs@*/ /*@=globs@*/
fi->_fnbf = rpmbfFree((rpmbf)fi->_fnbf); fi->_fnbf = rpmbfFree((rpmbf)fi->_fnbf);
fi->exclude = mireFreeAll(fi->exclude, fi->nexclude); fi->exclude = (miRE) mireFreeAll(fi->exclude, fi->nexclude);
fi->include = mireFreeAll(fi->include, fi->ninclude); fi->include = (miRE) mireFreeAll(fi->include, fi->ninclude);
fi->fn = _free(fi->fn); fi->fn = _free(fi->fn);
fi->apath = _free(fi->apath); fi->apath = _free(fi->apath);
fi->fmapflags = _free(fi->fmapflags); fi->fmapflags = _free(fi->fmapflags);
fi->obnl = _free(fi->obnl); fi->obnl = _free(fi->obnl);
fi->odnl = _free(fi->odnl); fi->odnl = _free(fi->odnl);
fi->fcontexts = _free(fi->fcontexts); fi->fcontexts = _free(fi->fcontexts);
skipping to change at line 1390 skipping to change at line 1397
if (c >= 'a' && c <= 'f') if (c >= 'a' && c <= 'f')
return (c - 'a') + 10; return (c - 'a') + 10;
return 0; return 0;
} }
#define _fdupestring(_h, _tag, _data) \ #define _fdupestring(_h, _tag, _data) \
he->tag = _tag; \ he->tag = _tag; \
xx = headerGet((_h), he, 0); \ xx = headerGet((_h), he, 0); \
_data = he->p.str; _data = he->p.str;
#define _fdupedata(_h, _tag, _data) \ #define _fdupedata(_h, _tag, _cast, _data) \
he->tag = _tag; \ he->tag = _tag; \
xx = headerGet((_h), he, 0); \ xx = headerGet((_h), he, 0); \
_data = he->p.ptr; _data = (_cast) he->p.ptr;
/*@-strictusereleased@*/ /*@-strictusereleased@*/
rpmfi rpmfiNew(const void * _ts, Header h, rpmTag tagN, int flags) rpmfi rpmfiNew(const void * _ts, Header h, rpmTag tagN, int flags)
{ {
/*@-castexpose@*/ /*@-castexpose@*/
const rpmts ts = (const rpmts) _ts; const rpmts ts = (const rpmts) _ts;
/*@=castexpose@*/ /*@=castexpose@*/
int scareMem = (flags & 0x1); int scareMem = (flags & 0x1);
HE_t he = memset(alloca(sizeof(*he)), 0, sizeof(*he)); HE_t he = (HE_t) memset(alloca(sizeof(*he)), 0, sizeof(*he));
rpmte p; rpmte p;
rpmfi fi = NULL; rpmfi fi = NULL;
const char * Type; const char * Type;
unsigned char * t; unsigned char * t;
pgpHashAlgo dalgo; pgpHashAlgo dalgo;
int xx; int xx;
int i; int i;
assert(scareMem == 0); /* XXX always allocate memory */ assert(scareMem == 0); /* XXX always allocate memory */
if (tagN == RPMTAG_BASENAMES) { if (tagN == RPMTAG_BASENAMES) {
skipping to change at line 1468 skipping to change at line 1475
he->tag = RPMTAG_OLDFILENAMES; he->tag = RPMTAG_OLDFILENAMES;
xx = headerGet(h, he, 0); xx = headerGet(h, he, 0);
} }
fi->bnl = he->p.argv; fi->bnl = he->p.argv;
fi->fc = he->c; fi->fc = he->c;
if (!xx) { if (!xx) {
fi->fc = 0; fi->fc = 0;
fi->dc = 0; fi->dc = 0;
goto exit; goto exit;
} }
_fdupedata(h, RPMTAG_DIRNAMES, fi->dnl); _fdupedata(h, RPMTAG_DIRNAMES, const char **, fi->dnl);
fi->dc = he->c; fi->dc = he->c;
/* XXX 3.0.x SRPM's can be used, relative fn's at RPMTAG_OLDFILENAMES. */ /* XXX 3.0.x SRPM's can be used, relative fn's at RPMTAG_OLDFILENAMES. */
if (fi->dc == 0 && fi->isSource) { if (fi->dc == 0 && fi->isSource) {
fi->dc = 1; fi->dc = 1;
fi->dnl = xcalloc(3, sizeof(*fi->dnl)); fi->dnl = (const char **) xcalloc(3, sizeof(*fi->dnl));
fi->dnl[0] = (const char *)&fi->dnl[2]; fi->dnl[0] = (const char *)&fi->dnl[2];
fi->dil = xcalloc(fi->fc, sizeof(*fi->dil)); fi->dil = (rpmuint32_t *) xcalloc(fi->fc, sizeof(*fi->dil));
} else { } else {
_fdupedata(h, RPMTAG_DIRINDEXES, fi->dil); _fdupedata(h, RPMTAG_DIRINDEXES, rpmuint32_t *, fi->dil);
} }
_fdupedata(h, RPMTAG_FILEMODES, fi->fmodes); _fdupedata(h, RPMTAG_FILEMODES, rpmuint16_t *, fi->fmodes);
_fdupedata(h, RPMTAG_FILEFLAGS, fi->fflags); _fdupedata(h, RPMTAG_FILEFLAGS, rpmuint32_t *, fi->fflags);
_fdupedata(h, RPMTAG_FILEVERIFYFLAGS, fi->vflags); _fdupedata(h, RPMTAG_FILEVERIFYFLAGS, rpmuint32_t *, fi->vflags);
_fdupedata(h, RPMTAG_FILESIZES, fi->fsizes); _fdupedata(h, RPMTAG_FILESIZES, rpmuint32_t *, fi->fsizes);
_fdupedata(h, RPMTAG_FILECOLORS, fi->fcolors); _fdupedata(h, RPMTAG_FILECOLORS, rpmuint32_t *, fi->fcolors);
fi->color = 0; fi->color = 0;
if (fi->fcolors != NULL) if (fi->fcolors != NULL)
for (i = 0; i < (int)fi->fc; i++) for (i = 0; i < (int)fi->fc; i++)
fi->color |= fi->fcolors[i]; fi->color |= fi->fcolors[i];
_fdupedata(h, RPMTAG_CLASSDICT, fi->cdict); _fdupedata(h, RPMTAG_CLASSDICT, const char **, fi->cdict);
fi->ncdict = he->c; fi->ncdict = he->c;
_fdupedata(h, RPMTAG_FILECLASS, fi->fcdictx); _fdupedata(h, RPMTAG_FILECLASS, rpmuint32_t *, fi->fcdictx);
_fdupedata(h, RPMTAG_DEPENDSDICT, fi->ddict); _fdupedata(h, RPMTAG_DEPENDSDICT, rpmuint32_t *, fi->ddict);
fi->nddict = he->c; fi->nddict = he->c;
_fdupedata(h, RPMTAG_FILEDEPENDSX, fi->fddictx); _fdupedata(h, RPMTAG_FILEDEPENDSX, rpmuint32_t *, fi->fddictx);
_fdupedata(h, RPMTAG_FILEDEPENDSN, fi->fddictn); _fdupedata(h, RPMTAG_FILEDEPENDSN, rpmuint32_t *, fi->fddictn);
_fdupedata(h, RPMTAG_FILESTATES, fi->fstates); _fdupedata(h, RPMTAG_FILESTATES, rpmuint8_t *, fi->fstates);
if (xx == 0 || fi->fstates == NULL) if (xx == 0 || fi->fstates == NULL)
fi->fstates = xcalloc(fi->fc, sizeof(*fi->fstates)); fi->fstates = (rpmuint8_t *) xcalloc(fi->fc, sizeof(*fi->fstates));
fi->action = FA_UNKNOWN; fi->action = FA_UNKNOWN;
fi->flags = 0; fi->flags = 0;
if (fi->actions == NULL) if (fi->actions == NULL)
fi->actions = xcalloc(fi->fc, sizeof(*fi->actions)); fi->actions = (int *) xcalloc(fi->fc, sizeof(*fi->actions));
/* XXX TR_REMOVED needs IOSM_MAP_{ABSOLUTE,ADDDOT} IOSM_ALL_HARDLINKS * / /* XXX TR_REMOVED needs IOSM_MAP_{ABSOLUTE,ADDDOT} IOSM_ALL_HARDLINKS * /
fi->mapflags = fi->mapflags =
IOSM_MAP_PATH | IOSM_MAP_MODE | IOSM_MAP_UID | IOSM_MAP_GID; IOSM_MAP_PATH | IOSM_MAP_MODE | IOSM_MAP_UID | IOSM_MAP_GID;
_fdupedata(h, RPMTAG_FILELINKTOS, fi->flinks); _fdupedata(h, RPMTAG_FILELINKTOS, const char **, fi->flinks);
_fdupedata(h, RPMTAG_FILELANGS, fi->flangs); _fdupedata(h, RPMTAG_FILELANGS, const char **, fi->flangs);
dalgo = PGPHASHALGO_ERROR; dalgo = PGPHASHALGO_ERROR;
fi->fdigestalgos = NULL; fi->fdigestalgos = NULL;
_fdupedata(h, RPMTAG_FILEDIGESTALGOS, fi->fdigestalgos); _fdupedata(h, RPMTAG_FILEDIGESTALGOS, rpmuint32_t *, fi->fdigestalgos);
if (fi->fdigestalgos) { if (fi->fdigestalgos) {
/* XXX Insure that all algorithms are either 0 or constant. */ /* XXX Insure that all algorithms are either 0 or constant. */
for (i = 0; i < (int)fi->fc; i++) { for (i = 0; i < (int)fi->fc; i++) {
if (fi->fdigestalgos[i] == 0) if (fi->fdigestalgos[i] == 0)
continue; continue;
if (dalgo == PGPHASHALGO_ERROR) if (dalgo == PGPHASHALGO_ERROR)
dalgo = (fi->fdigestalgos[i] & 0xff); dalgo = (pgpHashAlgo) (fi->fdigestalgos[i] & 0xff);
else else
assert(dalgo == (pgpHashAlgo)fi->fdigestalgos[i]); assert(dalgo == (pgpHashAlgo)fi->fdigestalgos[i]);
} }
fi->fdigestalgos = _free(fi->fdigestalgos); fi->fdigestalgos = _free(fi->fdigestalgos);
} else { } else {
he->tag = RPMTAG_FILEDIGESTALGO; he->tag = RPMTAG_FILEDIGESTALGO;
xx = headerGet(h, he, 0); xx = headerGet(h, he, 0);
if (xx) if (xx)
dalgo = he->p.ui32p[0]; dalgo = (pgpHashAlgo) he->p.ui32p[0];
he->p.ptr = _free(he->p.ptr); he->p.ptr = _free(he->p.ptr);
} }
switch (dalgo) { switch (dalgo) {
default: dalgo = PGPHASHALGO_MD5; fi->digestlen = 128/8; break; default: dalgo = PGPHASHALGO_MD5; fi->digestlen = 128/8; break;
case PGPHASHALGO_MD2: fi->digestlen = 128/8; break; case PGPHASHALGO_MD2: fi->digestlen = 128/8; break;
case PGPHASHALGO_MD5: fi->digestlen = 128/8; break; case PGPHASHALGO_MD5: fi->digestlen = 128/8; break;
case PGPHASHALGO_SHA1: fi->digestlen = 160/8; break; case PGPHASHALGO_SHA1: fi->digestlen = 160/8; break;
case PGPHASHALGO_RIPEMD128: fi->digestlen = 128/8; break; case PGPHASHALGO_RIPEMD128: fi->digestlen = 128/8; break;
case PGPHASHALGO_RIPEMD160: fi->digestlen = 160/8; break; case PGPHASHALGO_RIPEMD160: fi->digestlen = 160/8; break;
skipping to change at line 1555 skipping to change at line 1562
case PGPHASHALGO_RIPEMD320: fi->digestlen = 320/8; break; case PGPHASHALGO_RIPEMD320: fi->digestlen = 320/8; break;
case PGPHASHALGO_SHA224: fi->digestlen = 224/8; break; case PGPHASHALGO_SHA224: fi->digestlen = 224/8; break;
case PGPHASHALGO_SHA256: fi->digestlen = 256/8; break; case PGPHASHALGO_SHA256: fi->digestlen = 256/8; break;
case PGPHASHALGO_SHA384: fi->digestlen = 384/8; break; case PGPHASHALGO_SHA384: fi->digestlen = 384/8; break;
case PGPHASHALGO_SHA512: fi->digestlen = 512/8; break; case PGPHASHALGO_SHA512: fi->digestlen = 512/8; break;
case PGPHASHALGO_CRC32: fi->digestlen = 32/8; break; case PGPHASHALGO_CRC32: fi->digestlen = 32/8; break;
} }
fi->digestalgo = dalgo; fi->digestalgo = dalgo;
fi->digests = NULL; fi->digests = NULL;
_fdupedata(h, RPMTAG_FILEDIGESTS, fi->fdigests); _fdupedata(h, RPMTAG_FILEDIGESTS, const char **, fi->fdigests);
if (fi->fdigests) { if (fi->fdigests) {
t = xmalloc(fi->fc * fi->digestlen); t = (unsigned char *) xmalloc(fi->fc * fi->digestlen);
fi->digests = t; fi->digests = t;
for (i = 0; i < (int)fi->fc; i++) { for (i = 0; i < (int)fi->fc; i++) {
const char * fdigests; const char * fdigests;
int j; int j;
fdigests = fi->fdigests[i]; fdigests = fi->fdigests[i];
if (!(fdigests && *fdigests != '\0')) { if (!(fdigests && *fdigests != '\0')) {
memset(t, 0, fi->digestlen); memset(t, 0, fi->digestlen);
t += fi->digestlen; t += fi->digestlen;
continue; continue;
} }
for (j = 0; j < (int)fi->digestlen; j++, t++, fdigests += 2) for (j = 0; j < (int)fi->digestlen; j++, t++, fdigests += 2)
*t = (nibble(fdigests[0]) << 4) | nibble(fdigests[1]); *t = (nibble(fdigests[0]) << 4) | nibble(fdigests[1]);
} }
fi->fdigests = _free(fi->fdigests); fi->fdigests = _free(fi->fdigests);
} }
/* XXX TR_REMOVED doesn't need fmtimes, frdevs, finodes, or fcontexts * / /* XXX TR_REMOVED doesn't need fmtimes, frdevs, finodes, or fcontexts * /
_fdupedata(h, RPMTAG_FILEMTIMES, fi->fmtimes); _fdupedata(h, RPMTAG_FILEMTIMES, rpmuint32_t *, fi->fmtimes);
_fdupedata(h, RPMTAG_FILERDEVS, fi->frdevs); _fdupedata(h, RPMTAG_FILERDEVS, rpmuint16_t *, fi->frdevs);
_fdupedata(h, RPMTAG_FILEINODES, fi->finodes); _fdupedata(h, RPMTAG_FILEINODES, rpmuint32_t *, fi->finodes);
_fdupedata(h, RPMTAG_FILECONTEXTS, fi->fcontexts); _fdupedata(h, RPMTAG_FILECONTEXTS, const char **, fi->fcontexts);
fi->replacedSizes = xcalloc(fi->fc, sizeof(*fi->replacedSizes)); fi->replacedSizes = (rpmuint32_t *) xcalloc(fi->fc, sizeof(*fi->replace dSizes));
_fdupedata(h, RPMTAG_FILEUSERNAME, fi->fuser); _fdupedata(h, RPMTAG_FILEUSERNAME, const char **, fi->fuser);
_fdupedata(h, RPMTAG_FILEGROUPNAME, fi->fgroup); _fdupedata(h, RPMTAG_FILEGROUPNAME, const char **, fi->fgroup);
if (ts != NULL) if (ts != NULL)
if (fi != NULL) if (fi != NULL)
if ((p = rpmtsRelocateElement(ts)) != NULL && rpmteType(p) == TR_ADDED if ((p = rpmtsRelocateElement(ts)) != NULL && rpmteType(p) == TR_ADDED
&& headerIsEntry(h, RPMTAG_SOURCERPM) && headerIsEntry(h, RPMTAG_SOURCERPM)
&& !headerIsEntry(h, RPMTAG_ORIGBASENAMES)) && !headerIsEntry(h, RPMTAG_ORIGBASENAMES))
{ {
const char * fmt = rpmGetPath("%{?_autorelocate_path}", NULL); const char * fmt = rpmGetPath("%{?_autorelocate_path}", NULL);
const char * errstr; const char * errstr;
char * newPath; char * newPath;
skipping to change at line 1619 skipping to change at line 1626
continue; continue;
/*@=nullpass@*/ /*@=nullpass@*/
break; break;
} }
/* XXX test for incompatible arch triggering autorelocation is dumb. */ /* XXX test for incompatible arch triggering autorelocation is dumb. */
/* XXX DIEDIEDIE: used to test '... && p->archScore == 0' */ /* XXX DIEDIEDIE: used to test '... && p->archScore == 0' */
if (newPath != NULL && *newPath != '\0' && i == p->nrelocs) { if (newPath != NULL && *newPath != '\0' && i == p->nrelocs) {
p->relocs = p->relocs =
xrealloc(p->relocs, (p->nrelocs + 2) * sizeof(*p->relocs)); (rpmRelocation) xrealloc(p->relocs, (p->nrelocs + 2) * sizeo f(*p->relocs));
p->relocs[p->nrelocs].oldPath = xstrdup("/"); p->relocs[p->nrelocs].oldPath = xstrdup("/");
p->relocs[p->nrelocs].newPath = xstrdup(newPath); p->relocs[p->nrelocs].newPath = xstrdup(newPath);
p->autorelocatex = p->nrelocs; p->autorelocatex = p->nrelocs;
p->nrelocs++; p->nrelocs++;
p->relocs[p->nrelocs].oldPath = NULL; p->relocs[p->nrelocs].oldPath = NULL;
p->relocs[p->nrelocs].newPath = NULL; p->relocs[p->nrelocs].newPath = NULL;
} }
newPath = _free(newPath); newPath = _free(newPath);
/* XXX DYING */ /* XXX DYING */
if (fi->actions == NULL) if (fi->actions == NULL)
fi->actions = xcalloc(fi->fc, sizeof(*fi->actions)); fi->actions = (int *) xcalloc(fi->fc, sizeof(*fi->actions));
/*@-compdef@*/ /* FIX: fi->digests undefined */ /*@-compdef@*/ /* FIX: fi->digests undefined */
foo = relocateFileList(ts, fi, h, (iosmFileAction *) fi->actions); foo = relocateFileList(ts, fi, h, (iosmFileAction *) fi->actions);
/*@=compdef@*/ /*@=compdef@*/
(void)headerFree(fi->h); (void)headerFree(fi->h);
fi->h = NULL; fi->h = NULL;
fi->h = headerLink(foo); fi->h = headerLink(foo);
(void)headerFree(foo); (void)headerFree(foo);
foo = NULL; foo = NULL;
} }
if (fi->isSource && fi->dc == 1 && *fi->dnl[0] == '\0') { if (fi->isSource && fi->dc == 1 && *fi->dnl[0] == '\0') {
const char ** av = xcalloc(4+1, sizeof(*av)); const char ** av = (const char **) xcalloc(4+1, sizeof(*av));
char * te; char * te;
size_t nb; size_t nb;
xx = headerMacrosLoad(h); xx = headerMacrosLoad(h);
av[0] = rpmGenPath(rpmtsRootDir(ts), "%{_sourcedir}", ""); av[0] = rpmGenPath(rpmtsRootDir(ts), "%{_sourcedir}", "");
av[1] = rpmGenPath(rpmtsRootDir(ts), "%{_specdir}", ""); av[1] = rpmGenPath(rpmtsRootDir(ts), "%{_specdir}", "");
av[2] = rpmGenPath(rpmtsRootDir(ts), "%{_patchdir}", ""); av[2] = rpmGenPath(rpmtsRootDir(ts), "%{_patchdir}", "");
av[3] = rpmGenPath(rpmtsRootDir(ts), "%{_icondir}", ""); av[3] = rpmGenPath(rpmtsRootDir(ts), "%{_icondir}", "");
av[4] = NULL; av[4] = NULL;
xx = headerMacrosUnload(h); xx = headerMacrosUnload(h);
/* Hack up a header RPM_STRING_ARRAY_TYPE array. */ /* Hack up a header RPM_STRING_ARRAY_TYPE array. */
fi->dnl = _free(fi->dnl); fi->dnl = _free(fi->dnl);
fi->dc = 4; fi->dc = 4;
nb = fi->dc * sizeof(*av); nb = fi->dc * sizeof(*av);
for (i = 0; i < (int)fi->dc; i++) for (i = 0; i < (int)fi->dc; i++)
nb += strlen(av[i]) + sizeof("/"); nb += strlen(av[i]) + sizeof("/");
fi->dnl = xmalloc(nb); fi->dnl = (const char **) xmalloc(nb);
te = (char *) (&fi->dnl[fi->dc]); te = (char *) (&fi->dnl[fi->dc]);
*te = '\0'; *te = '\0';
for (i = 0; i < (int)fi->dc; i++) { for (i = 0; i < (int)fi->dc; i++) {
fi->dnl[i] = te; fi->dnl[i] = te;
te = stpcpy( stpcpy(te, av[i]), "/"); te = stpcpy( stpcpy(te, av[i]), "/");
*te++ = '\0'; *te++ = '\0';
} }
av = argvFree(av); av = argvFree(av);
/* Map basenames to appropriate directories. */ /* Map basenames to appropriate directories. */
skipping to change at line 1723 skipping to change at line 1730
/*@-compdef -nullstate@*/ /* FIX: rpmfi null annotations */ /*@-compdef -nullstate@*/ /* FIX: rpmfi null annotations */
return rpmfiLink(fi, (fi ? fi->Type : NULL)); return rpmfiLink(fi, (fi ? fi->Type : NULL));
/*@=compdef =nullstate@*/ /*@=compdef =nullstate@*/
} }
/*@=strictusereleased@*/ /*@=strictusereleased@*/
int rpmfiAddRelocation(rpmRelocation * relp, int * nrelp, int rpmfiAddRelocation(rpmRelocation * relp, int * nrelp,
const char * oldPath, const char * newPath) const char * oldPath, const char * newPath)
{ {
/*@-unqualifiedtrans@*/ /*@-unqualifiedtrans@*/
*relp = xrealloc(*relp, sizeof(**relp) * ((*nrelp) + 1)); *relp = (rpmRelocation) xrealloc(*relp, sizeof(**relp) * ((*nrelp) + 1) );
/*@=unqualifiedtrans@*/ /*@=unqualifiedtrans@*/
(*relp)[*nrelp].oldPath = (oldPath ? xstrdup(oldPath) : NULL); (*relp)[*nrelp].oldPath = (oldPath ? xstrdup(oldPath) : NULL);
(*relp)[*nrelp].newPath = (newPath ? xstrdup(newPath) : NULL); (*relp)[*nrelp].newPath = (newPath ? xstrdup(newPath) : NULL);
(*nrelp)++; (*nrelp)++;
return 0; return 0;
} }
rpmRelocation rpmfiFreeRelocations(rpmRelocation relocs) rpmRelocation rpmfiFreeRelocations(rpmRelocation relocs)
{ {
if (relocs) { if (relocs) {
skipping to change at line 1755 skipping to change at line 1762
{ {
rpmRelocation newr = NULL; rpmRelocation newr = NULL;
int nrelocs = 0; int nrelocs = 0;
if (relocs) { if (relocs) {
rpmRelocation r; rpmRelocation r;
int i; int i;
for (r = relocs; r->oldPath || r->newPath; r++) for (r = relocs; r->oldPath || r->newPath; r++)
nrelocs++; nrelocs++;
newr = xmalloc((nrelocs + 1) * sizeof(*relocs)); newr = (rpmRelocation) xmalloc((nrelocs + 1) * sizeof(*relocs));
for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) { for (i = 0, r = relocs; r->oldPath || r->newPath; i++, r++) {
newr[i].oldPath = r->oldPath ? xstrdup(r->oldPath) : NULL; newr[i].oldPath = r->oldPath ? xstrdup(r->oldPath) : NULL;
newr[i].newPath = r->newPath ? xstrdup(r->newPath) : NULL; newr[i].newPath = r->newPath ? xstrdup(r->newPath) : NULL;
} }
newr[i].oldPath = NULL; newr[i].oldPath = NULL;
newr[i].newPath = NULL; newr[i].newPath = NULL;
} }
if (nrelocsp) if (nrelocsp)
*nrelocsp = nrelocs; *nrelocsp = nrelocs;
skipping to change at line 1838 skipping to change at line 1845
{ {
const char * dn = name; const char * dn = name;
size_t dnlen = strlen(dn); size_t dnlen = strlen(dn);
const char ** fnames = NULL; const char ** fnames = NULL;
rpmuint16_t * fmodes = NULL; rpmuint16_t * fmodes = NULL;
DIR * dir; DIR * dir;
int xx; int xx;
int i, j; int i, j;
j = 0; j = 0;
fmodes = xcalloc(fi->fc, sizeof(*fmodes)); fmodes = (rpmuint16_t *) xcalloc(fi->fc, sizeof(*fmodes));
/* XXX todo full iteration is pig slow, fi->dil can be used for speedup . */ /* XXX todo full iteration is pig slow, fi->dil can be used for speedup . */
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
while ((i = rpmfiNext(fi)) >= 0) { while ((i = rpmfiNext(fi)) >= 0) {
const char * fn = rpmfiFN(fi); const char * fn = rpmfiFN(fi);
size_t fnlen = strlen(fn); size_t fnlen = strlen(fn);
if (fnlen <= dnlen) if (fnlen <= dnlen)
continue; continue;
if (strncmp(dn, fn, dnlen) || fn[dnlen] != '/') if (strncmp(dn, fn, dnlen) || fn[dnlen] != '/')
skipping to change at line 1900 skipping to change at line 1907
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
FClass = rpmfiFClass(fi); FClass = rpmfiFClass(fi);
if (FClass && *FClass != '\0') if (FClass && *FClass != '\0')
nb += strlen(FClass); nb += strlen(FClass);
nb += 1; nb += 1;
} }
/* Create and load file class argv array. */ /* Create and load file class argv array. */
av = xmalloc(nb); av = (const char **) xmalloc(nb);
t = ((char *) av) + ((ac + 1) * sizeof(*av)); t = ((char *) av) + ((ac + 1) * sizeof(*av));
ac = 0; ac = 0;
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
FClass = rpmfiFClass(fi); FClass = rpmfiFClass(fi);
av[ac++] = t; av[ac++] = t;
if (FClass && *FClass != '\0') if (FClass && *FClass != '\0')
t = stpcpy(t, FClass); t = stpcpy(t, FClass);
*t++ = '\0'; *t++ = '\0';
skipping to change at line 1953 skipping to change at line 1960
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
fcontext = rpmfiFContext(fi); fcontext = rpmfiFContext(fi);
if (fcontext && *fcontext != '\0') if (fcontext && *fcontext != '\0')
nb += strlen(fcontext); nb += strlen(fcontext);
nb += 1; nb += 1;
} }
/* Create and load argv array. */ /* Create and load argv array. */
av = xmalloc(nb); av = (const char **) xmalloc(nb);
t = ((char *) av) + ((ac + 1) * sizeof(*av)); t = ((char *) av) + ((ac + 1) * sizeof(*av));
ac = 0; ac = 0;
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
fcontext = rpmfiFContext(fi); fcontext = rpmfiFContext(fi);
av[ac++] = t; av[ac++] = t;
if (fcontext && *fcontext != '\0') if (fcontext && *fcontext != '\0')
t = stpcpy(t, fcontext); t = stpcpy(t, fcontext);
*t++ = '\0'; *t++ = '\0';
skipping to change at line 2008 skipping to change at line 2015
ac = 0; ac = 0;
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
const char *fn; const char *fn;
security_context_t scon = NULL; security_context_t scon = NULL;
fn = rpmfiFN(fi); fn = rpmfiFN(fi);
fcnb[ac] = lgetfilecon(fn, &scon); fcnb[ac] = lgetfilecon(fn, &scon);
if (fcnb[ac] > 0) { if (fcnb[ac] > 0) {
fctxt = xrealloc(fctxt, fctxtlen + fcnb[ac]); fctxt = (char *) xrealloc(fctxt, fctxtlen + fcnb[ac]);
memcpy(fctxt+fctxtlen, scon, fcnb[ac]); memcpy(fctxt+fctxtlen, scon, fcnb[ac]);
fctxtlen += fcnb[ac]; fctxtlen += fcnb[ac];
freecon(scon); freecon(scon);
} }
ac++; ac++;
} }
/* Create and load argv array from concatenated file contexts. */ /* Create and load argv array from concatenated file contexts. */
nb = (ac + 1) * sizeof(*av) + fctxtlen; nb = (ac + 1) * sizeof(*av) + fctxtlen;
av = xmalloc(nb); av = (const char **) xmalloc(nb);
t = ((char *) av) + ((ac + 1) * sizeof(*av)); t = ((char *) av) + ((ac + 1) * sizeof(*av));
if (fctxt != NULL && fctxtlen > 0) if (fctxt != NULL && fctxtlen > 0)
(void) memcpy(t, fctxt, fctxtlen); (void) memcpy(t, fctxt, fctxtlen);
ac = 0; ac = 0;
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
av[ac] = ""; av[ac] = "";
if (fcnb[ac] > 0) { if (fcnb[ac] > 0) {
av[ac] = t; av[ac] = t;
skipping to change at line 2089 skipping to change at line 2096
mode_t fmode; mode_t fmode;
security_context_t scon; security_context_t scon;
fn = rpmfiFN(fi); fn = rpmfiFN(fi);
fmode = rpmfiFMode(fi); fmode = rpmfiFMode(fi);
scon = NULL; scon = NULL;
/*@-moduncon@*/ /*@-moduncon@*/
if (matchpathcon(fn, fmode, &scon) == 0 && scon != NULL) { if (matchpathcon(fn, fmode, &scon) == 0 && scon != NULL) {
fcnb[ac] = strlen(scon) + 1; fcnb[ac] = strlen(scon) + 1;
if (fcnb[ac] > 0) { if (fcnb[ac] > 0) {
fctxt = xrealloc(fctxt, fctxtlen + fcnb[ac]); fctxt = (char *) xrealloc(fctxt, fctxtlen + fcnb[ac]);
memcpy(fctxt+fctxtlen, scon, fcnb[ac]); memcpy(fctxt+fctxtlen, scon, fcnb[ac]);
fctxtlen += fcnb[ac]; fctxtlen += fcnb[ac];
} }
freecon(scon); freecon(scon);
} }
/*@=moduncon@*/ /*@=moduncon@*/
ac++; ac++;
} }
/* Create and load argv array from concatenated file contexts. */ /* Create and load argv array from concatenated file contexts. */
nb = (ac + 1) * sizeof(*av) + fctxtlen; nb = (ac + 1) * sizeof(*av) + fctxtlen;
av = xmalloc(nb); av = (const char **) xmalloc(nb);
t = ((char *) av) + ((ac + 1) * sizeof(*av)); t = ((char *) av) + ((ac + 1) * sizeof(*av));
(void) memcpy(t, fctxt, fctxtlen); (void) memcpy(t, fctxt, fctxtlen);
ac = 0; ac = 0;
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
av[ac] = ""; av[ac] = "";
if (fcnb[ac] > 0) { if (fcnb[ac] > 0) {
av[ac] = t; av[ac] = t;
t += fcnb[ac]; t += fcnb[ac];
skipping to change at line 2185 skipping to change at line 2192
if (rpmdsNext(ds) < 0) if (rpmdsNext(ds) < 0)
/*@innercontinue@*/ continue; /*@innercontinue@*/ continue;
DNEVR = rpmdsDNEVR(ds); DNEVR = rpmdsDNEVR(ds);
if (DNEVR != NULL) if (DNEVR != NULL)
nb += strlen(DNEVR+2) + 1; nb += strlen(DNEVR+2) + 1;
} }
nb += 1; nb += 1;
} }
/* Create and load file depends argv array. */ /* Create and load file depends argv array. */
av = xmalloc(nb); av = (const char **) xmalloc(nb);
t = ((char *) av) + ((ac + 1) * sizeof(*av)); t = ((char *) av) + ((ac + 1) * sizeof(*av));
ac = 0; ac = 0;
fi = rpmfiInit(fi, 0); fi = rpmfiInit(fi, 0);
if (fi != NULL) if (fi != NULL)
while (rpmfiNext(fi) >= 0) { while (rpmfiNext(fi) >= 0) {
av[ac++] = t; av[ac++] = t;
ddict = NULL; ddict = NULL;
ndx = rpmfiFDepends(fi, &ddict); ndx = rpmfiFDepends(fi, &ddict);
if (ddict != NULL) if (ddict != NULL)
while (ndx-- > 0) { while (ndx-- > 0) {
 End of changes. 61 change blocks. 
71 lines changed or deleted 77 lines changed or added

This html diff was produced by rfcdiff 1.41. The latest version is available from http://tools.ietf.org/tools/rfcdiff/