rpm  5.4.15
header_internal.c
Go to the documentation of this file.
1 /*@-sizeoftype@*/
6 #include "system.h"
7 
8 #define _RPMTAG_INTERNAL
9 #include <header_internal.h>
10 
11 #include "debug.h"
12 
16 /*@observer@*/ /*@unchecked@*/
17 int rpm_typeAlign[16] = {
18  1,
19  1,
20  1,
21  2,
22  4,
23  8,
24  1,
25  1,
26  1,
27  1,
28  0,
29  0,
30  0,
31  0,
32  0,
33  0
34 };
35 
36 int headerVerifyInfo(rpmuint32_t il, rpmuint32_t dl, const void * pev, void * iv, int negate)
37 {
38 /*@-castexpose@*/
39  entryInfo pe = (entryInfo) pev;
40 /*@=castexpose@*/
41  entryInfo info = (entryInfo) iv;
42  rpmuint32_t i;
43 
44  for (i = 0; i < il; i++) {
45  info->tag = (rpmTag) ntohl(pe[i].tag);
46  info->type = (rpmTagType) ntohl(pe[i].type);
47  /* XXX Convert RPMTAG_FILESTATE to RPM_UINT8_TYPE. */
48  if (info->tag == 1029 && info->type == 1) {
49  info->type = RPM_UINT8_TYPE;
50  }
51  info->offset = (rpmint32_t) ntohl(pe[i].offset);
52 assert(negate || info->offset >= 0); /* XXX insurance */
53  if (negate)
54  info->offset = -info->offset;
55  info->count = (rpmuint32_t) ntohl(pe[i].count);
56 
57  if (hdrchkType(info->type))
58  return (int)i;
59  if (hdrchkAlign(info->type, info->offset))
60  return (int)i;
61  if (hdrchkRange((rpmint32_t)dl, info->offset))
62  return (int)i;
63  if (hdrchkData(info->count))
64  return (int)i;
65 
66  }
67  return -1;
68 }
69 /*@=sizeoftype@*/
int headerVerifyInfo(rpmuint32_t il, rpmuint32_t dl, const void *pev, void *iv, int negate)
Perform simple sanity and range checks on header tag(s).
rpmTagType type
int rpm_typeAlign[16]
Alignment needs (and sizeof scalars types) for internal rpm data types.
rpmTagCount count
unsigned int rpmuint32_t
Definition: rpmiotypes.h:28
struct entryInfo_s * entryInfo
Description of tag data.
#define hdrchkRange(_dl, _off)
Sanity check on range of data offset.
enum rpmTagType_e rpmTagType
Definition: rpmtag.h:47
#define hdrchkAlign(_type, _off)
int rpmint32_t
Definition: rpmiotypes.h:33
const char const int i
Definition: bson.h:778
const char char type
Definition: bson.h:908
#define hdrchkData(_nbytes)
Sanity check on data size and/or offset and/or count.
rpmint32_t offset
enum rpmTag_e rpmTag
Definition: rpmtag.h:470
#define hdrchkType(_type)
Sanity check on type values.