9
#include "Windows/Defs.h"
10
#include "Common/MyCom.h"
12
#include "../../Common/StreamUtils.h"
17
static UInt16 GetUInt16(const char *data)
19
return (UInt16)((Byte)data[1] | (((UInt16)(Byte)data[0]) << 8));
22
static UInt32 GetUInt32(const char *data)
25
((UInt32)(Byte)data[3]) |
26
(((UInt32)(Byte)data[2]) << 8) |
27
(((UInt32)(Byte)data[1]) << 16) |
28
(((UInt32)(Byte)data[0]) << 24);
31
static HRESULT RedSigHeaderSig(IInStream *inStream, CSigHeaderSig &h)
33
char dat[kCSigHeaderSigSize];
35
RINOK(ReadStream_FALSE(inStream, dat, kCSigHeaderSigSize));
36
memmove(h.Magic, cur, 4);
39
h.IndexLen = GetUInt32(cur);
41
h.DataLen = GetUInt32(cur);
45
HRESULT OpenArchive(IInStream *inStream)
48
char leadData[kLeadSize];
51
RINOK(ReadStream_FALSE(inStream, leadData, kLeadSize));
52
memmove(lead.Magic, cur, 4);
56
lead.Type = GetUInt16(cur);
58
lead.ArchNum = GetUInt16(cur);
60
memmove(lead.Name, cur, sizeof(lead.Name));
61
cur += sizeof(lead.Name);
62
lead.OSNum = GetUInt16(cur);
64
lead.SignatureType = GetUInt16(cur);
67
if (!lead.MagicCheck() || lead.Major < 3)
70
CSigHeaderSig sigHeader, header;
71
if(lead.SignatureType == RPMSIG_NONE)
75
else if(lead.SignatureType == RPMSIG_PGP262_1024)
78
RINOK(inStream->Seek(256, STREAM_SEEK_CUR, &pos));
80
else if(lead.SignatureType == RPMSIG_HEADERSIG)
82
RINOK(RedSigHeaderSig(inStream, sigHeader));
83
if(!sigHeader.MagicCheck())
85
UInt32 len = sigHeader.GetLostHeaderLen();
86
RINOK(inStream->Seek(len, STREAM_SEEK_CUR, &pos));
89
RINOK(inStream->Seek((pos / 8 + 1) * 8 - pos,
90
STREAM_SEEK_CUR, &pos));
96
RINOK(RedSigHeaderSig(inStream, header));
97
if(!header.MagicCheck())
99
int headerLen = header.GetLostHeaderLen();
102
RINOK(inStream->Seek(headerLen, STREAM_SEEK_CUR, &pos));