rpm  5.2.1
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 = iv;
42  rpmuint32_t i;
43 
44  for (i = 0; i < il; i++) {
45  info->tag = (rpmuint32_t) ntohl(pe[i].tag);
46  info->type = (rpmuint32_t) 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  pe[i].type = (rpmuint32_t) htonl(info->type);
51  }
52  info->offset = (rpmint32_t) ntohl(pe[i].offset);
53 assert(negate || info->offset >= 0); /* XXX insurance */
54  if (negate)
55  info->offset = -info->offset;
56  info->count = (rpmuint32_t) ntohl(pe[i].count);
57 
58  if (hdrchkType(info->type))
59  return (int)i;
60  if (hdrchkAlign(info->type, info->offset))
61  return (int)i;
62  if (!negate && hdrchkRange((rpmint32_t)dl, info->offset))
63  return (int)i;
64  if (hdrchkData(info->count))
65  return (int)i;
66 
67  }
68  return -1;
69 }
70 /*@=sizeoftype@*/