MCPcopy Create free account
hub / github.com/abbeycode/UnrarKit / ProcessExtra50

Method ProcessExtra50

Libraries/unrar/arcread.cpp:950–1196  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

948
949
950void Archive::ProcessExtra50(RawRead *Raw,size_t ExtraSize,BaseBlock *bb)
951{
952 // Read extra data from the end of block skipping any fields before it.
953 size_t ExtraStart=Raw->Size()-ExtraSize;
954 if (ExtraStart<Raw->GetPos())
955 return;
956 Raw->SetPos(ExtraStart);
957 while (Raw->DataLeft()>=2)
958 {
959 int64 FieldSize=Raw->GetV(); // Needs to be signed for check below and can be negative.
960 if (FieldSize<=0 || Raw->DataLeft()==0 || FieldSize>(int64)Raw->DataLeft())
961 break;
962 size_t NextPos=size_t(Raw->GetPos()+FieldSize);
963 uint64 FieldType=Raw->GetV();
964
965 FieldSize=int64(NextPos-Raw->GetPos()); // Field size without size and type fields.
966
967 if (FieldSize<0) // FieldType is longer than expected extra field size.
968 break;
969
970 if (bb->HeaderType==HEAD_MAIN)
971 {
972 MainHeader *hd=(MainHeader *)bb;
973 if (FieldType==MHEXTRA_LOCATOR)
974 {
975 hd->Locator=true;
976 uint Flags=(uint)Raw->GetV();
977 if ((Flags & MHEXTRA_LOCATOR_QLIST)!=0)
978 {
979 uint64 Offset=Raw->GetV();
980 if (Offset!=0) // 0 means that reserved space was not enough to write the offset.
981 hd->QOpenOffset=Offset+CurBlockPos;
982 }
983 if ((Flags & MHEXTRA_LOCATOR_RR)!=0)
984 {
985 uint64 Offset=Raw->GetV();
986 if (Offset!=0) // 0 means that reserved space was not enough to write the offset.
987 hd->RROffset=Offset+CurBlockPos;
988 }
989 }
990 }
991
992 if (bb->HeaderType==HEAD_FILE || bb->HeaderType==HEAD_SERVICE)
993 {
994 FileHeader *hd=(FileHeader *)bb;
995 switch(FieldType)
996 {
997 case FHEXTRA_CRYPT:
998 {
999 FileHeader *hd=(FileHeader *)bb;
1000 uint EncVersion=(uint)Raw->GetV();
1001 if (EncVersion>CRYPT_VERSION)
1002 {
1003 wchar Info[20];
1004 swprintf(Info,ASIZE(Info),L"x%u",EncVersion);
1005 UnkEncVerMsg(hd->FileName,Info);
1006 }
1007 else

Callers

nothing calls this directly

Calls 15

sha256_initFunction · 0.85
sha256_processFunction · 0.85
sha256_doneFunction · 0.85
wcsncatzFunction · 0.85
UnixSlashToDosFunction · 0.85
UtfToWideFunction · 0.85
GetPosMethod · 0.80
SetPosMethod · 0.80
DataLeftMethod · 0.80
GetVMethod · 0.80
Get1Method · 0.80
GetBMethod · 0.80

Tested by

no test coverage detected