diff options
author | Panu Matilainen <pmatilai@redhat.com> | 2008-05-12 16:53:26 +0300 |
---|---|---|
committer | Panu Matilainen <pmatilai@redhat.com> | 2008-05-12 16:53:26 +0300 |
commit | ecd8c6c44149b880e672accc416d593c551de72e (patch) | |
tree | d40e9df2e21e3c8c3ef413549d6089fa52887ba2 /lib | |
parent | f081d3da6658f7ea4ea7c3ba4355d2dcd34721fc (diff) | |
download | rpm-ecd8c6c44149b880e672accc416d593c551de72e.tar.gz rpm-ecd8c6c44149b880e672accc416d593c551de72e.tar.bz2 rpm-ecd8c6c44149b880e672accc416d593c551de72e.zip |
Move headerVerifyInfo() to header.[ch] where it logically belongs
- removes the need for copy-paste typeAlign array in package.c
Diffstat (limited to 'lib')
-rw-r--r-- | lib/header.c | 27 | ||||
-rw-r--r-- | lib/header.h | 11 | ||||
-rw-r--r-- | lib/package.c | 49 | ||||
-rw-r--r-- | lib/rpmlib.h | 11 |
4 files changed, 38 insertions, 60 deletions
diff --git a/lib/header.c b/lib/header.c index beee4dafe..a64cb18eb 100644 --- a/lib/header.c +++ b/lib/header.c @@ -139,6 +139,33 @@ Header headerNew(void) return headerLink(h); } +int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate) +{ + entryInfo pe = (entryInfo) pev; + entryInfo info = iv; + int i; + + for (i = 0; i < il; i++) { + info->tag = ntohl(pe[i].tag); + info->type = ntohl(pe[i].type); + info->offset = ntohl(pe[i].offset); + if (negate) + info->offset = -info->offset; + info->count = ntohl(pe[i].count); + + if (hdrchkType(info->type)) + return i; + if (hdrchkAlign(info->type, info->offset)) + return i; + if (!negate && hdrchkRange(dl, info->offset)) + return i; + if (hdrchkData(info->count)) + return i; + + } + return -1; +} + /** */ static int indexCmp(const void * avp, const void * bvp) diff --git a/lib/header.h b/lib/header.h index e382028a3..d9aa6d30c 100644 --- a/lib/header.h +++ b/lib/header.h @@ -201,6 +201,17 @@ void headerUnsort(Header h); unsigned int headerSizeof(Header h, enum hMagic magicp); /** \ingroup header + * Perform simple sanity and range checks on header tag(s). + * @param il no. of tags in header + * @param dl no. of bytes in header data. + * @param pev 1st element in tag array, big-endian + * @param iv failing (or last) tag element, host-endian + * @param negate negative offset expected? + * @return -1 on success, otherwise failing tag element index + */ +int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate); + +/** \ingroup header * Convert header to on-disk representation. * @param h header (with pointers) * @return on-disk header blob (i.e. with offsets) diff --git a/lib/package.c b/lib/package.c index ff7c718c9..6a27f8b8e 100644 --- a/lib/package.c +++ b/lib/package.c @@ -32,28 +32,6 @@ static unsigned char const header_magic[8] = { 0x8e, 0xad, 0xe8, 0x01, 0x00, 0x00, 0x00, 0x00 }; -/** - * Alignment needs (and sizeof scalars types) for internal rpm data types. - */ -static int const typeAlign[16] = { - 1, /*!< RPM_NULL_TYPE */ - 1, /*!< RPM_CHAR_TYPE */ - 1, /*!< RPM_INT8_TYPE */ - 2, /*!< RPM_INT16_TYPE */ - 4, /*!< RPM_INT32_TYPE */ - 8, /*!< RPM_INT64_TYPE */ - 1, /*!< RPM_STRING_TYPE */ - 1, /*!< RPM_BIN_TYPE */ - 1, /*!< RPM_STRING_ARRAY_TYPE */ - 1, /*!< RPM_I18NSTRING_TYPE */ - 0, - 0, - 0, - 0, - 0, - 0 -}; - void headerMergeLegacySigs(Header h, const Header sigh) { HFD_t hfd = (HFD_t) headerFreeData; @@ -235,33 +213,6 @@ static int rpmtsStashKeyid(rpmts ts) return 0; } -int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate) -{ - entryInfo pe = (entryInfo) pev; - entryInfo info = iv; - int i; - - for (i = 0; i < il; i++) { - info->tag = ntohl(pe[i].tag); - info->type = ntohl(pe[i].type); - info->offset = ntohl(pe[i].offset); - if (negate) - info->offset = -info->offset; - info->count = ntohl(pe[i].count); - - if (hdrchkType(info->type)) - return i; - if (hdrchkAlign(info->type, info->offset)) - return i; - if (!negate && hdrchkRange(dl, info->offset)) - return i; - if (hdrchkData(info->count)) - return i; - - } - return -1; -} - /** * Check header consistency, performing headerGetEntry() the hard way. * diff --git a/lib/rpmlib.h b/lib/rpmlib.h index 5f7039eaa..8a6819e19 100644 --- a/lib/rpmlib.h +++ b/lib/rpmlib.h @@ -136,17 +136,6 @@ void rpmFreeRpmrc(void); int rpmVersionCompare(Header first, Header second); /** \ingroup header - * Perform simple sanity and range checks on header tag(s). - * @param il no. of tags in header - * @param dl no. of bytes in header data. - * @param pev 1st element in tag array, big-endian - * @param iv failing (or last) tag element, host-endian - * @param negate negative offset expected? - * @return -1 on success, otherwise failing tag element index - */ -int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate); - -/** \ingroup header * Check for supported payload format in header. * @param h header to check * @return RPMRC_OK if supported, RPMRC_FAIL otherwise |