DmgHandler.cpp (p7zip_15.14.1_src_all) | : | DmgHandler.cpp (p7zip_16.02_src_all) | ||
---|---|---|---|---|
skipping to change at line 37 | skipping to change at line 37 | |||
// #include <stdio.h> | // #include <stdio.h> | |||
#define PRF(x) // x | #define PRF(x) // x | |||
#define Get16(p) GetBe16(p) | #define Get16(p) GetBe16(p) | |||
#define Get32(p) GetBe32(p) | #define Get32(p) GetBe32(p) | |||
#define Get64(p) GetBe64(p) | #define Get64(p) GetBe64(p) | |||
static const Byte k_Base64Table[256] = | static const Byte k_Base64Table[256] = | |||
{ | { | |||
64,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | 66,77,77,77,77,77,77,77,77,65,65,77,77,65,77,77, | |||
77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77,77,77,77,77,77,62,77,64,77,63,52,53,54,55,56,57,58,59,60,61, | 65,77,77,77,77,77,77,77,77,77,77,62,77,77,77,63, | |||
77,77,77,77,77,77, | 52,53,54,55,56,57,58,59,60,61,77,77,77,64,77,77, | |||
77, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24, | 77, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9,10,11,12,13,14, | |||
25,77,77,77,77,77, | 15,16,17,18,19,20,21,22,23,24,25,77,77,77,77,77, | |||
77,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50, | 77,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40, | |||
51,77,77,77,77,77, | 41,42,43,44,45,46,47,48,49,50,51,77,77,77,77,77, | |||
77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77, | |||
77,77,77,77,77,77 | 77,77,77,77,77,77,77,77,77,77,77,77,77,77,77,77 | |||
}; | }; | |||
static Byte *Base64ToBin(Byte *dest, const char *src) | static Byte *Base64ToBin(Byte *dest, const char *src) | |||
{ | { | |||
UInt32 val = 1; | UInt32 val = 1; | |||
UInt32 c = k_Base64Table[(Byte)(*src++)]; | ||||
for (;;) | for (;;) | |||
{ | { | |||
/* | UInt32 c = k_Base64Table[(Byte)(*src++)]; | |||
UInt32 c = (Byte)(*src++); | ||||
if (c >= 'A') | ||||
{ | ||||
if (c <= 'Z') c -= 'A'; | ||||
else if (c >= 'a' && c <= 'z') c -= 'a' - 26; | ||||
else continue; | ||||
} | ||||
else if (c >= '0') | ||||
{ | ||||
if (c <= '9') c += 52 - '0'; | ||||
else if (c == '=') break; | ||||
else continue; | ||||
} | ||||
else if (c == '+') c = 62; | ||||
else if (c == '/') c = 63; | ||||
else if (c == 0) break; | ||||
else continue; | ||||
*/ | ||||
// UInt32 c = k_Base64Table[(Byte)(*src++)]; | ||||
if (c < 64) | if (c < 64) | |||
{ | { | |||
val = (val << 6) | c; | val = (val << 6) | c; | |||
c = k_Base64Table[(Byte)(*src++)]; | ||||
if ((val & ((UInt32)1 << 24)) == 0) | if ((val & ((UInt32)1 << 24)) == 0) | |||
continue; | continue; | |||
dest[0] = (Byte)(val >> 16); | dest[0] = (Byte)(val >> 16); | |||
dest[1] = (Byte)(val >> 8); | dest[1] = (Byte)(val >> 8); | |||
dest[2] = (Byte)(val); | dest[2] = (Byte)(val); | |||
dest += 3; | dest += 3; | |||
val = 1; | val = 1; | |||
continue; | continue; | |||
} | } | |||
if (c == 64) | ||||
if (c == 65) // space | ||||
continue; | ||||
if (c == 64) // '=' | ||||
break; | break; | |||
c = k_Base64Table[(Byte)(*src++)]; | ||||
if (c == 66 && val == 1) // end of string | ||||
return dest; | ||||
return NULL; | ||||
} | } | |||
if (val >= ((UInt32)1 << 12)) | if (val < (1 << 12)) | |||
return NULL; | ||||
if (val & (1 << 18)) | ||||
{ | { | |||
if (val >= ((UInt32)1 << 18)) | *dest++ = (Byte)(val >> 10); | |||
*dest++ = (Byte)(val >> 16); | *dest++ = (Byte)(val >> 2); | |||
*dest++ = (Byte)(val); | ||||
} | } | |||
else if (k_Base64Table[(Byte)(*src++)] != 64) // '=' | ||||
return NULL; | ||||
else | ||||
*dest++ = (Byte)(val >> 4); | ||||
return dest; | for (;;) | |||
{ | ||||
Byte c = k_Base64Table[(Byte)(*src++)]; | ||||
if (c == 65) // space | ||||
continue; | ||||
if (c == 66) // end of string | ||||
return dest; | ||||
return NULL; | ||||
} | ||||
} | } | |||
namespace NArchive { | namespace NArchive { | |||
namespace NDmg { | namespace NDmg { | |||
enum | enum | |||
{ | { | |||
METHOD_ZERO_0 = 0, | METHOD_ZERO_0 = 0, | |||
METHOD_COPY = 1, | METHOD_COPY = 1, | |||
METHOD_ZERO_2 = 2, // without file CRC calculation | METHOD_ZERO_2 = 2, // without file CRC calculation | |||
skipping to change at line 722 | skipping to change at line 731 | |||
continue; | continue; | |||
CByteBuffer rawBuf; | CByteBuffer rawBuf; | |||
unsigned destLen = 0; | unsigned destLen = 0; | |||
{ | { | |||
const AString *dataString = GetStringFromKeyPair(item, "Data", "data"); | const AString *dataString = GetStringFromKeyPair(item, "Data", "data"); | |||
if (!dataString) | if (!dataString) | |||
return S_FALSE; | return S_FALSE; | |||
destLen = dataString->Len() / 4 * 3 + 4; | destLen = dataString->Len() / 4 * 3 + 4; | |||
rawBuf.Alloc(destLen); | rawBuf.Alloc(destLen); | |||
destLen = (unsigned)(Base64ToBin(rawBuf, *dataString) - rawBuf); | { | |||
const Byte *endPtr = Base64ToBin(rawBuf, *dataString); | ||||
if (!endPtr) | ||||
return S_FALSE; | ||||
destLen = (unsigned)(endPtr - rawBuf); | ||||
} | ||||
#ifdef DMG_SHOW_RAW | #ifdef DMG_SHOW_RAW | |||
CExtraFile &extra = _extras.AddNew(); | CExtraFile &extra = _extras.AddNew(); | |||
{ | { | |||
char extraName[16]; | char extraName[16]; | |||
ConvertUInt32ToString(_files.Size(), extraName); | ConvertUInt32ToString(_files.Size(), extraName); | |||
extra.Name = extraName; | extra.Name = extraName; | |||
} | } | |||
extra.Data.CopyFrom(rawBuf, destLen); | extra.Data.CopyFrom(rawBuf, destLen); | |||
#endif | #endif | |||
} | } | |||
End of changes. 12 change blocks. | ||||
46 lines changed or deleted | 53 lines changed or added |