rpm 5.3.12
rpmdb/header_internal.c
Go to the documentation of this file.
00001 /*@-sizeoftype@*/
00006 #include "system.h"
00007 
00008 #define _RPMTAG_INTERNAL
00009 #include <header_internal.h>
00010 
00011 #include "debug.h"
00012 
00016 /*@observer@*/ /*@unchecked@*/
00017 int rpm_typeAlign[16] =  {
00018     1,  
00019     1,  
00020     1,  
00021     2,  
00022     4,  
00023     8,  
00024     1,  
00025     1,  
00026     1,  
00027     1,  
00028     0,
00029     0,
00030     0,
00031     0,
00032     0,
00033     0
00034 };
00035 
00036 int headerVerifyInfo(rpmuint32_t il, rpmuint32_t dl, const void * pev, void * iv, int negate)
00037 {
00038 /*@-castexpose@*/
00039     entryInfo pe = (entryInfo) pev;
00040 /*@=castexpose@*/
00041     entryInfo info = iv;
00042     rpmuint32_t i;
00043 
00044     for (i = 0; i < il; i++) {
00045         info->tag = (rpmuint32_t) ntohl(pe[i].tag);
00046         info->type = (rpmuint32_t) ntohl(pe[i].type);
00047         /* XXX Convert RPMTAG_FILESTATE to RPM_UINT8_TYPE. */
00048         if (info->tag == 1029 && info->type == 1) {
00049             info->type = RPM_UINT8_TYPE;
00050         }
00051         info->offset = (rpmint32_t) ntohl(pe[i].offset);
00052 assert(negate || info->offset >= 0);    /* XXX insurance */
00053         if (negate)
00054             info->offset = -info->offset;
00055         info->count = (rpmuint32_t) ntohl(pe[i].count);
00056 
00057         if (hdrchkType(info->type))
00058             return (int)i;
00059         if (hdrchkAlign(info->type, info->offset))
00060             return (int)i;
00061         if (!negate && hdrchkRange((rpmint32_t)dl, info->offset))
00062             return (int)i;
00063         if (hdrchkData(info->count))
00064             return (int)i;
00065 
00066     }
00067     return -1;
00068 }
00069 /*@=sizeoftype@*/