This change likely needs some explanation.
I'd like to flip from explicit (i.e. each tag carries a type) to implcit
(i.e. each tag has one and only one a priori known type) typing.
I can only do this if the tag type table compiled into rpm is known
reliable.
Since the table is automagically generated with an awk script from
comments in rpmdb/rpmtag.h, I really have no clue whether the types
in the table are reliable or not. I also have little clue what
additional
hackery has been done to what people are calling "rpm" in the wild.
So I've added an explicit comparison that will lead to a harmless
warning message if the table values are incorrect.
Note "harmless" please, but report any spew so that I can design
a fix.
This patch also fixes the type of RPMTAG_FILESTATES the one
wartlet from removing RPM_CHAR_TYPE. The failure
is quite loud and noisy and scary.
However the instant detection verifies that the sanity check
on header tag types is quite effective, and even more so now
that unused (in *.rpm packages) tag data types have been eliminated,
so that the range of permitted tag type values is narrower.
I'll leave the warning msg for a couple of days before changing from
explicit
to implicit data typing. The end result will be nuking all occurences of
he->t = RPM_FOO_TYPE
in rpmlib code, and freeing up 32 bits in the current Header index for
whatever purpose might be necessary down the road.
73 de Jeff
On Nov 11, 2007, at 6:59 PM, Jeff Johnson wrote:
> RPM Package Manager, CVS Repository
> http://rpm5.org/cvs/
>
> ______________________________________________________________________
> ______
>
> Server: rpm5.org Name: Jeff Johnson
> Root: /v/rpm/cvs Email: jbj@rpm5.org
> Module: rpm Date: 12-Nov-2007
> 00:59:20
> Branch: HEAD Handle: 2007111123591901
>
> Modified files:
> rpm CHANGES TODO
> rpm/rpmdb hdrinline.h header_internal.c
> librpmdb.vers
> rpmtag.h tagname.c
>
> Log:
> - hmmm, tagno's 261 and 269 are fishy, skip tagTypeValidate for
> now.
> - add tagTypeValidate sanity check before flipping to implicit
> typing.
> - fix: "RPMTAG_FILESTATES has RPM_CHAR_TYPE=1 instead of 2".
>
> Summary:
> Revision Changes Path
> 1.1807 +3 -0 rpm/CHANGES
> 1.9 +3 -3 rpm/TODO
> 1.29 +9 -4 rpm/rpmdb/hdrinline.h
> 1.14 +5 -0 rpm/rpmdb/header_internal.c
> 1.26 +1 -0 rpm/rpmdb/librpmdb.vers
> 1.3 +3 -2 rpm/rpmdb/rpmtag.h
> 1.9 +12 -0 rpm/rpmdb/tagname.c
>
> ______________________________________________________________________
> ______
>
> patch -p0 <<'@@ .'
> Index: rpm/CHANGES
>
> ======================================================================
> ======
> $ cvs diff -u -r1.1806 -r1.1807 CHANGES
> --- rpm/CHANGES 11 Nov 2007 22:07:45 -0000 1.1806
> +++ rpm/CHANGES 11 Nov 2007 23:59:19 -0000 1.1807
> @@ -1,4 +1,7 @@
> 4.5 -> 5.0:
> + - jbj: hmmm, tagno's 261 and 269 are fishy, skip
> tagTypeValidate for now.
> + - jbj: add tagTypeValidate sanity check before flipping to
> implicit typing.
> + - jbj: fix: "RPMTAG_FILESTATES has RPM_CHAR_TYPE=1 instead
> of 2".
> - jbj: eliminate headerGetLangs, query
> RPMTAG_HEADERI18NTABLE instead.
> - jbj: eliminate headerGetRawEntry(), noone can possibly need.
> - jbj: eliminate headerDump, query with --xml or --yaml
> instead.
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/TODO
>
> ======================================================================
> ======
> $ cvs diff -u -r1.8 -r1.9 TODO
> --- rpm/TODO 11 Nov 2007 22:30:43 -0000 1.8
> +++ rpm/TODO 11 Nov 2007 23:59:19 -0000 1.9
> @@ -53,13 +53,13 @@
> - rse: xar/ has weak (think RPM_CHECK_LIB) support its third-
> party libraries LibXML, OpenSSL, etc.
> - jbj: RPM_I18NSTRING_TYPE is likely still wonky, certainly
> true for
> rpm-python h['summary'] access.
> - - jbj: RPMTAG_FILESTATE needs s/1/2/ type when header is
> loaded to succeed
> + + jbj: RPMTAG_FILESTATE needs s/1/2/ type when header is
> loaded to succeed
> eliminating RPM_CHAR_TYPE. This is likely to show up oddly with a
> header sanity check failure somewhere, because RPM_MIN_TYPE has
> been
> - changed.
> + changed. [DONE]
> - jbj: C++ and C have different rules regarding typedef'd
> enums like rpmTag.
> The definitions and usage are currently split awkwardly between
> - rpmtag.h and header.h
> + rpmtag.h and header.h.
>
> o to be resolved before RPM 5.0.0:
> - rse: NEWS polishing
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmdb/hdrinline.h
>
> ======================================================================
> ======
> $ cvs diff -u -r1.28 -r1.29 hdrinline.h
> --- rpm/rpmdb/hdrinline.h 8 Nov 2007 18:08:27 -0000 1.28
> +++ rpm/rpmdb/hdrinline.h 11 Nov 2007 23:59:20 -0000 1.29
> @@ -251,6 +251,8 @@
> return (h2hv(h)->hdrfreetag) (h, data, type);
> }
>
> +void tagTypeValidate(HE_t he);
> +
> /*
> * Retrieve extension or tag value.
> *
> @@ -263,8 +265,12 @@
> int headerGetExtension(Header h, HE_t he, /*@unused@*/ unsigned
> int flags)
> /*@modifies *he @*/
> {
> + int xx;
> if (h == NULL) return 0;
> - return (h2hv(h)->hdrext) (h, he->tag, &he->t, &he->p, &he->c);
> + xx = (h2hv(h)->hdrext) (h, he->tag, &he->t, &he->p, &he->c);
> +/* XXX verify that explicit and implicit types are identical. */
> +if (xx) tagTypeValidate(he);
> + return xx;
> }
>
> /** \ingroup header
> @@ -281,13 +287,12 @@
> /*@modifies h @*/
> {
> int xx;
> +/* XXX verify that explicit and implicit types are identical. */
> +tagTypeValidate(he);
> if (he->append)
> xx = (h2hv(h)->hdraddorappend) (h, he->tag, he->t, he->p.ptr,
> he->c);
> else
> xx = (h2hv(h)->hdradd) (h, he->tag, he->t, he->p.ptr, he->c);
> -#if 0
> -assert(xx);
> -#endif
> return xx;
> }
>
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmdb/header_internal.c
>
> ======================================================================
> ======
> $ cvs diff -u -r1.13 -r1.14 header_internal.c
> --- rpm/rpmdb/header_internal.c 11 Nov 2007 22:07:46 -0000 1.13
> +++ rpm/rpmdb/header_internal.c 11 Nov 2007 23:59:20 -0000 1.14
> @@ -43,6 +43,11 @@
> for (i = 0; i < il; i++) {
> info->tag = ntohl(pe[i].tag);
> info->type = ntohl(pe[i].type);
> + /* XXX Convert RPMTAG_FILESTATE to RPM_UINT8_TYPE. */
> + if (info->tag == 1029 && info->type == 1) {
> + info->type = RPM_UINT8_TYPE;
> + pe[i].type = htonl(info->type);
> + }
> info->offset = ntohl(pe[i].offset);
> if (negate)
> info->offset = -info->offset;
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmdb/librpmdb.vers
>
> ======================================================================
> ======
> $ cvs diff -u -r1.25 -r1.26 librpmdb.vers
> --- rpm/rpmdb/librpmdb.vers 11 Nov 2007 02:23:44 -0000 1.25
> +++ rpm/rpmdb/librpmdb.vers 11 Nov 2007 23:59:20 -0000 1.26
> @@ -106,6 +106,7 @@
> rpmwfFree;
> rpmVerifySignature;
> sqlitevec;
> + tagTypeValidate;
> XrpmdbLink;
> XrpmdbUnlink;
> local:
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmdb/rpmtag.h
>
> ======================================================================
> ======
> $ cvs diff -u -r1.2 -r1.3 rpmtag.h
> --- rpm/rpmdb/rpmtag.h 20 Oct 2007 01:47:17 -0000 1.2
> +++ rpm/rpmdb/rpmtag.h 11 Nov 2007 23:59:20 -0000 1.3
> @@ -1,12 +1,12 @@
> #ifndef H_RPMTAG
> #define H_RPMTAG
>
> +#include <header.h>
> +
> /** \ingroup header
> * \file rpmdb/rpmtag.h
> */
>
> -#include <header.h>
> -
> #ifdef __cplusplus
> extern "C" {
> #endif
> @@ -371,6 +371,7 @@
> return ((*rpmTags->tagValue)(tagstr));
> /*@=type@*/
> }
> +
> #endif
>
> #ifdef __cplusplus
> @@ .
> patch -p0 <<'@@ .'
> Index: rpm/rpmdb/tagname.c
>
> ======================================================================
> ======
> $ cvs diff -u -r1.8 -r1.9 tagname.c
> --- rpm/rpmdb/tagname.c 11 Nov 2007 22:07:46 -0000 1.8
> +++ rpm/rpmdb/tagname.c 11 Nov 2007 23:59:20 -0000 1.9
> @@ -271,3 +271,15 @@
> }
> return -1;
> }
> +
> +/**
> + * Validate that implicit and explicit types are identical.
> + * @param he tag container
> + */
> +void tagTypeValidate(HE_t he)
> +{
> +/* XXX hack around known borkage for now. */
> +if (!(he->tag == 261 || he->tag == 269))
> +if ((tagType(he->tag) & 0xffff) != he->t)
> +fprintf(stderr, "==> warning: tag %u type(0x%x) != implicit type
> (0x%x)\n", he->tag, he->t, tagType(he->tag));
> +}
> @@ .
> ______________________________________________________________________
> RPM Package Manager http://rpm5.org
> CVS Sources Repository rpm-cvs@rpm5.org
Received on Mon Nov 12 01:15:11 2007