RPM Package Manager, CVS Repository
  http://rpm5.org/cvs/
  ____________________________________________________________________________

  Server: rpm5.org                         Name:   Jeff Johnson
  Root:   /v/rpm/cvs                       Email:  [EMAIL PROTECTED]
  Module: rpm                              Date:   08-Sep-2007 20:55:46
  Branch: HEAD                             Handle: 2007090819554501

  Modified files:
    rpm                     CHANGES
    rpm/lib                 librpm.vers package.c
    rpm/rpmdb               header.c header_internal.c header_internal.h
                            librpmdb.vers

  Log:
    - refactor headerVerifyInfo().

  Summary:
    Revision    Changes     Path
    1.1624      +1  -0      rpm/CHANGES
    1.12        +0  -1      rpm/lib/librpm.vers
    2.152       +0  -50     rpm/lib/package.c
    1.64        +0  -50     rpm/rpmdb/header.c
    1.7         +31 -0      rpm/rpmdb/header_internal.c
    1.18        +62 -0      rpm/rpmdb/header_internal.h
    1.16        +1  -0      rpm/rpmdb/librpmdb.vers
  ____________________________________________________________________________

  patch -p0 <<'@@ .'
  Index: rpm/CHANGES
  ============================================================================
  $ cvs diff -u -r1.1623 -r1.1624 CHANGES
  --- rpm/CHANGES       8 Sep 2007 18:22:54 -0000       1.1623
  +++ rpm/CHANGES       8 Sep 2007 18:55:45 -0000       1.1624
  @@ -1,4 +1,5 @@
   4.5 -> 5.0:
  +    - jbj: refactor headerVerifyInfo().
       - jbj: pour the amber over the corpse of the rpmlead. Ptooey! R.I.P.
       - jbj: stub in rpmpkgFoo() i/o methods.
       - jbj: refactor rpmlead I/O routines into rpmdb/pkgio.c.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/librpm.vers
  ============================================================================
  $ cvs diff -u -r1.11 -r1.12 librpm.vers
  --- rpm/lib/librpm.vers       8 Sep 2007 16:17:33 -0000       1.11
  +++ rpm/lib/librpm.vers       8 Sep 2007 18:55:45 -0000       1.12
  @@ -36,7 +36,6 @@
       headerCheck;
       headerMergeLegacySigs;
       headerRegenSigHeader;
  -    headerVerifyInfo;
       IDTXfree;
       IDTXglob;
       IDTXgrow;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/lib/package.c
  ============================================================================
  $ cvs diff -u -r2.151 -r2.152 package.c
  --- rpm/lib/package.c 8 Sep 2007 18:22:54 -0000       2.151
  +++ rpm/lib/package.c 8 Sep 2007 18:55:45 -0000       2.152
  @@ -42,56 +42,6 @@
   extern int _nolead;
   extern int _nosigh;
   
  -/**
  - * Alignment needs (and sizeof scalars types) for internal rpm data types.
  - */
  -/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  -static int 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
  -};
  -
  -/**
  - * Sanity check on no. of tags.
  - * This check imposes a limit of 65K tags, more than enough.
  - */
  -#define hdrchkTags(_ntags)      ((_ntags) & 0xffff0000)
  -
  -/**
  - * Sanity check on type values.
  - */
  -#define hdrchkType(_type) ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE)
  -
  -/**
  - * Sanity check on data size and/or offset and/or count.
  - * This check imposes a limit of 16 MB, more than enough.
  - */
  -#define hdrchkData(_nbytes) ((_nbytes) & 0xff000000)
  -
  -/**
  - * Sanity check on data alignment for data type.
  - */
  -#define hdrchkAlign(_type, _off)     ((_off) & (typeAlign[_type]-1))
  -
  -/**
  - * Sanity check on range of data offset.
  - */
  -#define hdrchkRange(_dl, _off)               ((_off) < 0 || (_off) > (_dl))
  -
   void headerMergeLegacySigs(Header h, const Header sigh)
   {
       HFD_t hfd = (HFD_t) headerFreeData;
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header.c
  ============================================================================
  $ cvs diff -u -r1.63 -r1.64 header.c
  --- rpm/rpmdb/header.c        6 Sep 2007 07:42:22 -0000       1.63
  +++ rpm/rpmdb/header.c        8 Sep 2007 18:55:46 -0000       1.64
  @@ -52,29 +52,6 @@
   };
   
   /** \ingroup header
  - * Alignment needed for header data types.
  - */
  -/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  -static int 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 */
  -    1,  /*!< RPM_ASN1_TYPE */
  -    1,  /*!< RPM_OPENPGP_TYPE */
  -    0,
  -    0,
  -    0,
  -    0
  -};
  -
  -/** \ingroup header
    * Size of header data types.
    */
   /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  @@ -103,33 +80,6 @@
   /[EMAIL PROTECTED]@*/
   static size_t headerMaxbytes = (32*1024*1024);
   
  -/**
  - * Sanity check on no. of tags.
  - * This check imposes a limit of 65K tags, more than enough.
  - */ 
  -#define hdrchkTags(_ntags)   ((_ntags) & 0xffff0000)
  -
  -/**
  - * Sanity check on type values.
  - */
  -#define hdrchkType(_type) ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE)
  -
  -/**
  - * Sanity check on data size and/or offset and/or count.
  - * This check imposes a limit of 16Mb, more than enough.
  - */ 
  -#define hdrchkData(_nbytes)  ((_nbytes) & 0xff000000)
  -
  -/**
  - * Sanity check on alignment for data type.
  - */
  -#define hdrchkAlign(_type, _off)     ((_off) & (typeAlign[_type]-1))
  -
  -/**
  - * Sanity check on range of data offset.
  - */
  -#define hdrchkRange(_dl, _off)               ((_off) < 0 || (_off) > (_dl))
  -
   /[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
   HV_t hdrVec; /* forward reference */
   
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header_internal.c
  ============================================================================
  $ cvs diff -u -r1.6 -r1.7 header_internal.c
  --- rpm/rpmdb/header_internal.c       9 Jun 2007 19:08:00 -0000       1.6
  +++ rpm/rpmdb/header_internal.c       8 Sep 2007 18:55:46 -0000       1.7
  @@ -9,6 +9,37 @@
   
   #include "debug.h"
   
  +int headerVerifyInfo(int il, int dl, const void * pev, void * iv, int negate)
  +{
  +/[EMAIL PROTECTED]@*/
  +    entryInfo pe = (entryInfo) pev;
  +/[EMAIL PROTECTED]@*/
  +    entryInfo info = iv;
  +    int i;
  +
  +/[EMAIL PROTECTED]@*/
  +    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;
  +
  +    }
  +/[EMAIL PROTECTED]@*/
  +    return -1;
  +}
  +
   /[EMAIL PROTECTED]@*/
   char ** headerGetLangs(Header h)
   {
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/header_internal.h
  ============================================================================
  $ cvs diff -u -r1.17 -r1.18 header_internal.h
  --- rpm/rpmdb/header_internal.h       19 Aug 2007 21:12:23 -0000      1.17
  +++ rpm/rpmdb/header_internal.h       8 Sep 2007 18:55:46 -0000       1.18
  @@ -11,6 +11,56 @@
   #include <netinet/in.h>
   #endif  /* __LCLINT__ */
   
  +/**
  + * Alignment needs (and sizeof scalars types) for internal rpm data types.
  + */
  +/[EMAIL PROTECTED]@*/ /[EMAIL PROTECTED]@*/
  +static int 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
  +};
  +
  +/**
  + * Sanity check on no. of tags.
  + * This check imposes a limit of 65K tags, more than enough.
  + */
  +#define hdrchkTags(_ntags)      ((_ntags) & 0xffff0000)
  +
  +/**
  + * Sanity check on type values.
  + */
  +#define hdrchkType(_type) ((_type) < RPM_MIN_TYPE || (_type) > RPM_MAX_TYPE)
  +
  +/**
  + * Sanity check on data size and/or offset and/or count.
  + * This check imposes a limit of 16 MB, more than enough.
  + */
  +#define hdrchkData(_nbytes) ((_nbytes) & 0xff000000)
  +
  +/**
  + * Sanity check on data alignment for data type.
  + */
  +#define hdrchkAlign(_type, _off)     ((_off) & (typeAlign[_type]-1))
  +
  +/**
  + * Sanity check on range of data offset.
  + */
  +#define hdrchkRange(_dl, _off)               ((_off) < 0 || (_off) > (_dl))
  +
   #define      INDEX_MALLOC_SIZE       8
   
   /*
  @@ -150,6 +200,18 @@
   extern "C" {
   #endif
   
  +/**
  + * 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)
  +     /[EMAIL PROTECTED] *iv @*/;
  +
   /** \ingroup header
    * Return array of locales found in header.
    * The array is terminated with a NULL sentinel.
  @@ .
  patch -p0 <<'@@ .'
  Index: rpm/rpmdb/librpmdb.vers
  ============================================================================
  $ cvs diff -u -r1.15 -r1.16 librpmdb.vers
  --- rpm/rpmdb/librpmdb.vers   8 Sep 2007 18:22:56 -0000       1.15
  +++ rpm/rpmdb/librpmdb.vers   8 Sep 2007 18:55:46 -0000       1.16
  @@ -35,6 +35,7 @@
       headerMacrosLoad;
       headerMacrosUnload;
       headerNEVRA;
  +    headerVerifyInfo;
       hGetColor;
       _init;
       _nolead;
  @@ .
______________________________________________________________________
RPM Package Manager                                    http://rpm5.org
CVS Sources Repository                                rpm-cvs@rpm5.org

Reply via email to