rpm
4.5
|
#include "system.h"
#include <netinet/in.h>
#include <rpmio_internal.h>
#include <rpmlib.h>
#include "rpmts.h"
#include "rpmevr.h"
#include "misc.h"
#include "rpmlead.h"
#include "header_internal.h"
#include "signature.h"
#include "debug.h"
Go to the source code of this file.
Defines | |
#define | alloca_strdup(_s) strcpy(alloca(strlen(_s)+1), (_s)) |
#define | hdrchkTags(_ntags) ((_ntags) & 0xffff0000) |
Sanity check on no. | |
#define | hdrchkType(_type) ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE) |
Sanity check on type values. | |
#define | hdrchkData(_nbytes) ((_nbytes) & 0xff000000) |
Sanity check on data size and/or offset and/or count. | |
#define | hdrchkAlign(_type, _off) ((_off) & (typeAlign[_type]-1)) |
Sanity check on data alignment for data type. | |
#define | hdrchkRange(_dl, _off) ((_off) < 0 || (_off) > (_dl)) |
Sanity check on range of data offset. | |
#define | _chk(_mask) (sigtag == 0 && !(vsflags & (_mask))) |
Functions | |
static int | dncmp (const void *a, const void *b) |
static void | compressFilelist (Header h) |
Convert absolute path tag to (dirname,basename,dirindex) tags. | |
static void | rpm3to4 (Header h) |
void | headerMergeLegacySigs (Header h, const Header sigh) |
Translate and merge legacy signature tags into header. | |
Header | headerRegenSigHeader (const Header h, int noArchiveSize) |
Regenerate signature header. | |
static int | rpmtsStashKeyid (rpmts ts) |
Remember current key id. | |
int | headerVerifyInfo (int il, int dl, const void *pev, void *iv, int negate) |
Perform simple sanity and range checks on header tag(s). | |
rpmRC | headerCheck (rpmts ts, const void *uh, size_t uc, const char **msg) |
Check header consistency, performing headerGetEntry() the hard way. | |
rpmRC | rpmReadHeader (rpmts ts, FD_t fd, Header *hdrp, const char **msg) |
Return checked and loaded header. | |
rpmRC | rpmReadPackageFile (rpmts ts, FD_t fd, const char *fn, Header *hdrp) |
Return package header from file handle, verifying digests/signatures. | |
Variables | |
static int | _print_pkts = 0 |
static unsigned int | nkeyids_max = 256 |
static unsigned int | nkeyids = 0 |
static unsigned int | nextkeyid = 0 |
static unsigned int * | keyids |
static unsigned char | header_magic [8] |
static int | typeAlign [16] |
Alignment needs (and sizeof scalars types) for internal rpm data types. |
Definition in file package.c.
#define _chk | ( | _mask | ) | (sigtag == 0 && !(vsflags & (_mask))) |
Referenced by rpmReadPackageFile().
#define alloca_strdup | ( | _s | ) | strcpy(alloca(strlen(_s)+1), (_s)) |
#define hdrchkAlign | ( | _type, | |
_off | |||
) | ((_off) & (typeAlign[_type]-1)) |
Sanity check on data alignment for data type.
Definition at line 96 of file package.c.
Referenced by headerVerifyInfo().
#define hdrchkData | ( | _nbytes | ) | ((_nbytes) & 0xff000000) |
Sanity check on data size and/or offset and/or count.
This check imposes a limit of 16 MB, more than enough.
Definition at line 91 of file package.c.
Referenced by headerMergeLegacySigs(), headerVerifyInfo(), and rpmReadHeader().
#define hdrchkRange | ( | _dl, | |
_off | |||
) | ((_off) < 0 || (_off) > (_dl)) |
Sanity check on range of data offset.
Definition at line 101 of file package.c.
Referenced by headerVerifyInfo().
#define hdrchkTags | ( | _ntags | ) | ((_ntags) & 0xffff0000) |
Sanity check on no.
of tags. This check imposes a limit of 65K tags, more than enough.
Definition at line 80 of file package.c.
Referenced by rpmReadHeader().
#define hdrchkType | ( | _type | ) | ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE) |
Sanity check on type values.
Definition at line 85 of file package.c.
Referenced by headerMergeLegacySigs(), and headerVerifyInfo().
static void compressFilelist | ( | Header | h | ) | [static] |
Convert absolute path tag to (dirname,basename,dirindex) tags.
h | header |
Definition at line 337 of file package.c.
References alloca(), dncmp(), headerAddEntry(), headerFreeData(), headerGetEntryMinMemory(), headerIsEntry(), headerRemoveEntry(), RPM_INT32_TYPE, and RPM_STRING_ARRAY_TYPE.
Referenced by rpm3to4().
static int dncmp | ( | const void * | a, |
const void * | b | ||
) | [static] |
Definition at line 323 of file package.c.
Referenced by compressFilelist().
Check header consistency, performing headerGetEntry() the hard way.
Sanity checks on the header are performed while looking for a header-only digest or signature to verify the blob. If found, the digest or signature is verified.
ts | transaction set |
uh | unloaded header blob |
uc | no. of bytes in blob (or 0 to disable) |
*msg | signature verification msg |
Definition at line 691 of file package.c.
References _, _free(), _print_pkts, alloca(), entryInfo_s::count, pgpDigParams_s::hash_algo, pgpDig_s::hdrmd5ctx, pgpDig_s::hdrsha1ctx, header_magic, headerVerifyInfo(), indexEntry_s::info, pgpDig_s::nbytes, entryInfo_s::offset, PGPHASHALGO_SHA1, pgpPrtPkts(), REGION_TAG_COUNT, RPM_BIN_TYPE, RPM_STRING_TYPE, RPMDIGEST_NONE, rpmDigestInit(), rpmDigestUpdate(), rpmIsDebug, RPMMESS_ERROR, rpmMessage, RPMRC_FAIL, RPMRC_NOTFOUND, RPMRC_OK, rpmswEnter(), rpmswExit(), RPMTAG_HEADERIMMUTABLE, RPMTS_OP_DIGEST, rpmtsCleanDig(), rpmtsDig(), rpmtsOp(), rpmtsSetSig(), rpmtsVSFlags(), rpmVerifySignature(), RPMVSF_NODSAHEADER, RPMVSF_NORSAHEADER, RPMVSF_NOSHA1HEADER, pgpDig_s::signature, snprintf(), entryInfo_s::tag, entryInfo_s::type, pgpDigParams_s::version, xmalloc(), and xstrdup().
Referenced by rpmpsmStage(), rpmReadHeader(), rpmts_HdrCheck(), rpmtsInitIterator(), and rpmtsRebuildDB().
int headerVerifyInfo | ( | int | il, |
int | dl, | ||
const void * | pev, | ||
void * | iv, | ||
int | negate | ||
) |
Perform simple sanity and range checks on header tag(s).
il | no. of tags in header |
dl | no. of bytes in header data. |
pev | 1st element in tag array, big-endian |
iv | failing (or last) tag element, host-endian |
negate | negative offset expected? |
Definition at line 647 of file package.c.
References entryInfo_s::count, hdrchkAlign, hdrchkData, hdrchkRange, hdrchkType, entryInfo_s::offset, entryInfo_s::tag, and entryInfo_s::type.
Referenced by headerCheck(), and rpmReadSignature().
static void rpm3to4 | ( | Header | h | ) | [static] |
Definition at line 431 of file package.c.
References alloca(), compressFilelist(), headerAddOrAppendEntry(), headerFreeTag(), headerGetEntry(), headerNVR(), name, RPM_INT32_TYPE, RPM_STRING_ARRAY_TYPE, RPMSENSE_EQUAL, and stpcpy().
Referenced by rpmReadPackageFile().
Return checked and loaded header.
ts | transaction set |
fd | file handle |
hdrp | address of header (or NULL) |
*msg | verification error message (or NULL) |
Definition at line 1016 of file package.c.
References _, _free(), block(), errno, fdGetOPath(), FDSTAT_READ, Fileno(), headerToken_s::flags, hdrchkData, hdrchkTags, header_magic, headerCheck(), HEADERFLAG_ALLOCATED, headerFree(), headerGetStatbuf(), headerLink(), headerLoad(), headerSetEndOff(), headerSetOrigin(), headerSetStartOff(), Realpath(), RPMRC_FAIL, RPMRC_OK, snprintf(), _FD_s::stats, timedRead(), urlPath(), xmalloc(), and xstrdup().
Referenced by rpmReadPackageFile().
Return package header from file handle, verifying digests/signatures.
ts | transaction set |
fd | file handle |
fn | file name |
hdrp | address of header (or NULL) |
Definition at line 1138 of file package.c.
References _, _chk, _free(), _print_pkts, alloca(), rpmop_s::count, _FD_s::digests, fdInitDigest(), fdstat_op(), FDSTAT_READ, Fileno(), Fread(), Fstrerror(), pgpDigParams_s::hash_algo, _FDDIGEST_s::hashalgo, _FDDIGEST_s::hashctx, pgpDig_s::hdrmd5ctx, pgpDig_s::hdrsha1ctx, header_magic, headerFree(), headerFreeData(), headerGetEntry(), headerIsEntry(), headerLink(), headerMergeLegacySigs(), rpmlead::major, pgpDig_s::md5ctx, pgpDig_s::nbytes, _FD_s::ndigests, PGPHASHALGO_MD5, PGPHASHALGO_RIPEMD160, PGPHASHALGO_SHA1, PGPHASHALGO_SHA256, PGPHASHALGO_SHA384, PGPHASHALGO_SHA512, pgpPrtPkts(), readLead(), rpm3to4(), RPMDIGEST_NONE, rpmDigestInit(), rpmDigestUpdate(), RPMERR_FREAD, RPMERR_NEWPACKAGE, RPMERR_SIGGEN, rpmError, rpmFreeSignature(), rpmIsDebug, RPMMESS_DEBUG, RPMMESS_ERROR, RPMMESS_WARNING, rpmMessage, RPMRC_FAIL, RPMRC_NOKEY, RPMRC_NOTFOUND, RPMRC_NOTTRUSTED, RPMRC_OK, rpmReadHeader(), rpmReadSignature(), RPMSIGTAG_DSA, RPMSIGTAG_GPG, RPMSIGTAG_MD5, RPMSIGTAG_PGP, RPMSIGTAG_PGP5, RPMSIGTAG_RSA, RPMSIGTAG_SHA1, rpmswAdd(), rpmswEnter(), rpmswExit(), rpmswSub(), RPMTAG_HEADERIMMUTABLE, RPMTS_OP_DIGEST, RPMTS_OP_READHDR, RPMTS_OP_SIGNATURE, rpmtsCleanDig(), rpmtsDig(), rpmtsOp(), rpmtsSetSig(), rpmtsStashKeyid(), rpmtsVSFlags(), rpmVerifySignature(), RPMVSF_NEEDPAYLOAD, RPMVSF_NODSA, RPMVSF_NODSAHEADER, RPMVSF_NOMD5, RPMVSF_NORSA, RPMVSF_NORSAHEADER, RPMVSF_NOSHA1HEADER, pgpDig_s::sha1ctx, pgpDig_s::signature, rpmlead::signature_type, _FD_s::stats, and pgpDigParams_s::version.
Referenced by IDTXglob(), readRPM(), rpmgiReadHeader(), rpmInstall(), rpmInstallSourcePackage(), rpmts_HdrFromFdno(), rpmtsRun(), and rpmtsSolve().
static int rpmtsStashKeyid | ( | rpmts | ts | ) | [static] |
Remember current key id.
ts | transaction set |
Definition at line 608 of file package.c.
References keyids, nextkeyid, nkeyids, nkeyids_max, pgpGrab(), rpmtsDig(), rpmtsSig(), rpmtsSignature(), pgpDigParams_s::signid, and xrealloc().
Referenced by rpmReadPackageFile().
int _print_pkts = 0 [static] |
Definition at line 37 of file package.c.
Referenced by headerCheck(), rpmReadPackageFile(), and rpmVerifySignatures().
unsigned char header_magic[8] [static] |
{ 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00 }
Definition at line 49 of file package.c.
Referenced by headerCheck(), rpmReadHeader(), and rpmReadPackageFile().
unsigned int* keyids [static] |
Definition at line 46 of file package.c.
Referenced by rpmtsStashKeyid().
unsigned int nextkeyid = 0 [static] |
Definition at line 44 of file package.c.
Referenced by rpmtsStashKeyid().
unsigned int nkeyids = 0 [static] |
Definition at line 42 of file package.c.
Referenced by rpmtsStashKeyid().
unsigned int nkeyids_max = 256 [static] |
Definition at line 40 of file package.c.
Referenced by rpmtsStashKeyid().