diff options
63 files changed, 729 insertions, 639 deletions
diff --git a/C/7zArcIn.c b/C/7zArcIn.c index 4dc3ba1..f6f6e7c 100644 --- a/C/7zArcIn.c +++ b/C/7zArcIn.c | |||
| @@ -11,7 +11,7 @@ | |||
| 11 | #include "CpuArch.h" | 11 | #include "CpuArch.h" |
| 12 | 12 | ||
| 13 | #define MY_ALLOC(T, p, size, alloc) \ | 13 | #define MY_ALLOC(T, p, size, alloc) \ |
| 14 | { if ((p = (T *)ISzAlloc_Alloc(alloc, (size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; } | 14 | { if ((p = (T *)ISzAlloc_Alloc(alloc, (size_t)(size) * sizeof(T))) == NULL) return SZ_ERROR_MEM; } |
| 15 | 15 | ||
| 16 | #define MY_ALLOC_ZE(T, p, size, alloc) \ | 16 | #define MY_ALLOC_ZE(T, p, size, alloc) \ |
| 17 | { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) } | 17 | { if ((size) == 0) p = NULL; else MY_ALLOC(T, p, size, alloc) } |
| @@ -22,8 +22,6 @@ | |||
| 22 | #define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \ | 22 | #define MY_ALLOC_ZE_AND_CPY(to, size, from, alloc) \ |
| 23 | { if ((size) == 0) to = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } } | 23 | { if ((size) == 0) to = NULL; else { MY_ALLOC_AND_CPY(to, size, from, alloc) } } |
| 24 | 24 | ||
| 25 | #define k7zMajorVersion 0 | ||
| 26 | |||
| 27 | enum EIdEnum | 25 | enum EIdEnum |
| 28 | { | 26 | { |
| 29 | k7zIdEnd, | 27 | k7zIdEnd, |
| @@ -52,15 +50,13 @@ enum EIdEnum | |||
| 52 | k7zIdEncodedHeader, | 50 | k7zIdEncodedHeader, |
| 53 | k7zIdStartPos, | 51 | k7zIdStartPos, |
| 54 | k7zIdDummy | 52 | k7zIdDummy |
| 55 | // k7zNtSecure, | ||
| 56 | // k7zParent, | ||
| 57 | // k7zIsReal | ||
| 58 | }; | 53 | }; |
| 59 | 54 | ||
| 60 | const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; | 55 | const Byte k7zSignature[k7zSignatureSize] = {'7', 'z', 0xBC, 0xAF, 0x27, 0x1C}; |
| 61 | 56 | ||
| 62 | #define SzBitUi32s_INIT(p) { (p)->Defs = NULL; (p)->Vals = NULL; } | 57 | #define SzBitUi32s_INIT(p) { (p)->Defs = NULL; (p)->Vals = NULL; } |
| 63 | 58 | ||
| 59 | Z7_FORCE_INLINE | ||
| 64 | static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) | 60 | static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) |
| 65 | { | 61 | { |
| 66 | if (num == 0) | 62 | if (num == 0) |
| @@ -76,6 +72,7 @@ static SRes SzBitUi32s_Alloc(CSzBitUi32s *p, size_t num, ISzAllocPtr alloc) | |||
| 76 | return SZ_OK; | 72 | return SZ_OK; |
| 77 | } | 73 | } |
| 78 | 74 | ||
| 75 | Z7_FORCE_INLINE | ||
| 79 | static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) | 76 | static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) |
| 80 | { | 77 | { |
| 81 | ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; | 78 | ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; |
| @@ -84,13 +81,14 @@ static void SzBitUi32s_Free(CSzBitUi32s *p, ISzAllocPtr alloc) | |||
| 84 | 81 | ||
| 85 | #define SzBitUi64s_INIT(p) { (p)->Defs = NULL; (p)->Vals = NULL; } | 82 | #define SzBitUi64s_INIT(p) { (p)->Defs = NULL; (p)->Vals = NULL; } |
| 86 | 83 | ||
| 84 | Z7_FORCE_INLINE | ||
| 87 | static void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc) | 85 | static void SzBitUi64s_Free(CSzBitUi64s *p, ISzAllocPtr alloc) |
| 88 | { | 86 | { |
| 89 | ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; | 87 | ISzAlloc_Free(alloc, p->Defs); p->Defs = NULL; |
| 90 | ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; | 88 | ISzAlloc_Free(alloc, p->Vals); p->Vals = NULL; |
| 91 | } | 89 | } |
| 92 | 90 | ||
| 93 | 91 | Z7_NO_INLINE | |
| 94 | static void SzAr_Init(CSzAr *p) | 92 | static void SzAr_Init(CSzAr *p) |
| 95 | { | 93 | { |
| 96 | p->NumPackStreams = 0; | 94 | p->NumPackStreams = 0; |
| @@ -110,23 +108,22 @@ static void SzAr_Init(CSzAr *p) | |||
| 110 | p->RangeLimit = 0; | 108 | p->RangeLimit = 0; |
| 111 | } | 109 | } |
| 112 | 110 | ||
| 111 | Z7_NO_INLINE | ||
| 113 | static void SzAr_Free(CSzAr *p, ISzAllocPtr alloc) | 112 | static void SzAr_Free(CSzAr *p, ISzAllocPtr alloc) |
| 114 | { | 113 | { |
| 115 | ISzAlloc_Free(alloc, p->PackPositions); | 114 | ISzAlloc_Free(alloc, p->PackPositions); |
| 116 | SzBitUi32s_Free(&p->FolderCRCs, alloc); | 115 | SzBitUi32s_Free(&p->FolderCRCs, alloc); |
| 117 | |||
| 118 | ISzAlloc_Free(alloc, p->FoCodersOffsets); | 116 | ISzAlloc_Free(alloc, p->FoCodersOffsets); |
| 119 | ISzAlloc_Free(alloc, p->FoStartPackStreamIndex); | 117 | ISzAlloc_Free(alloc, p->FoStartPackStreamIndex); |
| 120 | ISzAlloc_Free(alloc, p->FoToCoderUnpackSizes); | 118 | ISzAlloc_Free(alloc, p->FoToCoderUnpackSizes); |
| 121 | ISzAlloc_Free(alloc, p->FoToMainUnpackSizeIndex); | 119 | ISzAlloc_Free(alloc, p->FoToMainUnpackSizeIndex); |
| 122 | ISzAlloc_Free(alloc, p->CoderUnpackSizes); | 120 | ISzAlloc_Free(alloc, p->CoderUnpackSizes); |
| 123 | |||
| 124 | ISzAlloc_Free(alloc, p->CodersData); | 121 | ISzAlloc_Free(alloc, p->CodersData); |
| 125 | 122 | ||
| 126 | SzAr_Init(p); | 123 | SzAr_Init(p); |
| 127 | } | 124 | } |
| 128 | 125 | ||
| 129 | 126 | Z7_NO_INLINE | |
| 130 | void SzArEx_Init(CSzArEx *p) | 127 | void SzArEx_Init(CSzArEx *p) |
| 131 | { | 128 | { |
| 132 | SzAr_Init(&p->db); | 129 | SzAr_Init(&p->db); |
| @@ -150,6 +147,7 @@ void SzArEx_Init(CSzArEx *p) | |||
| 150 | SzBitUi64s_INIT(&p->CTime) | 147 | SzBitUi64s_INIT(&p->CTime) |
| 151 | } | 148 | } |
| 152 | 149 | ||
| 150 | Z7_NO_INLINE | ||
| 153 | void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) | 151 | void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) |
| 154 | { | 152 | { |
| 155 | ISzAlloc_Free(alloc, p->UnpackPositions); | 153 | ISzAlloc_Free(alloc, p->UnpackPositions); |
| @@ -172,15 +170,6 @@ void SzArEx_Free(CSzArEx *p, ISzAllocPtr alloc) | |||
| 172 | } | 170 | } |
| 173 | 171 | ||
| 174 | 172 | ||
| 175 | static int TestSignatureCandidate(const Byte *testBytes) | ||
| 176 | { | ||
| 177 | unsigned i; | ||
| 178 | for (i = 0; i < k7zSignatureSize; i++) | ||
| 179 | if (testBytes[i] != k7zSignature[i]) | ||
| 180 | return 0; | ||
| 181 | return 1; | ||
| 182 | } | ||
| 183 | |||
| 184 | #define SzData_CLEAR(p) { (p)->Data = NULL; (p)->Size = 0; } | 173 | #define SzData_CLEAR(p) { (p)->Data = NULL; (p)->Size = 0; } |
| 185 | 174 | ||
| 186 | #define SZ_READ_BYTE_SD_NOCHECK(_sd_, dest) \ | 175 | #define SZ_READ_BYTE_SD_NOCHECK(_sd_, dest) \ |
| @@ -199,14 +188,9 @@ static int TestSignatureCandidate(const Byte *testBytes) | |||
| 199 | #define SKIP_DATA(sd, size) { sd->Size -= (size_t)(size); sd->Data += (size_t)(size); } | 188 | #define SKIP_DATA(sd, size) { sd->Size -= (size_t)(size); sd->Data += (size_t)(size); } |
| 200 | #define SKIP_DATA2(sd, size) { sd.Size -= (size_t)(size); sd.Data += (size_t)(size); } | 189 | #define SKIP_DATA2(sd, size) { sd.Size -= (size_t)(size); sd.Data += (size_t)(size); } |
| 201 | 190 | ||
| 202 | #define SZ_READ_32(dest) if (sd.Size < 4) return SZ_ERROR_ARCHIVE; \ | ||
| 203 | dest = GetUi32(sd.Data); SKIP_DATA2(sd, 4); | ||
| 204 | |||
| 205 | static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) | 191 | static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) |
| 206 | { | 192 | { |
| 207 | Byte firstByte, mask; | 193 | unsigned firstByte, mask, i, v; |
| 208 | unsigned i; | ||
| 209 | UInt32 v; | ||
| 210 | 194 | ||
| 211 | SZ_READ_BYTE(firstByte) | 195 | SZ_READ_BYTE(firstByte) |
| 212 | if ((firstByte & 0x80) == 0) | 196 | if ((firstByte & 0x80) == 0) |
| @@ -223,18 +207,18 @@ static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) | |||
| 223 | SZ_READ_BYTE(mask) | 207 | SZ_READ_BYTE(mask) |
| 224 | *value = v | ((UInt32)mask << 8); | 208 | *value = v | ((UInt32)mask << 8); |
| 225 | mask = 0x20; | 209 | mask = 0x20; |
| 226 | for (i = 2; i < 8; i++) | 210 | for (i = 2 * 8; i < 8 * 8; i += 8) |
| 227 | { | 211 | { |
| 228 | Byte b; | 212 | unsigned b; |
| 229 | if ((firstByte & mask) == 0) | 213 | if ((firstByte & mask) == 0) |
| 230 | { | 214 | { |
| 231 | const UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1); | 215 | const UInt64 highPart = (unsigned)firstByte & (unsigned)(mask - 1); |
| 232 | *value |= (highPart << (8 * i)); | 216 | *value |= (highPart << i); |
| 233 | return SZ_OK; | 217 | return SZ_OK; |
| 234 | } | 218 | } |
| 235 | SZ_READ_BYTE(b) | ||
| 236 | *value |= ((UInt64)b << (8 * i)); | ||
| 237 | mask >>= 1; | 219 | mask >>= 1; |
| 220 | SZ_READ_BYTE(b) | ||
| 221 | *value |= ((UInt64)b << i); | ||
| 238 | } | 222 | } |
| 239 | return SZ_OK; | 223 | return SZ_OK; |
| 240 | } | 224 | } |
| @@ -242,7 +226,7 @@ static Z7_NO_INLINE SRes ReadNumber(CSzData *sd, UInt64 *value) | |||
| 242 | 226 | ||
| 243 | static Z7_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) | 227 | static Z7_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) |
| 244 | { | 228 | { |
| 245 | Byte firstByte; | 229 | unsigned firstByte; |
| 246 | UInt64 value64; | 230 | UInt64 value64; |
| 247 | if (sd->Size == 0) | 231 | if (sd->Size == 0) |
| 248 | return SZ_ERROR_ARCHIVE; | 232 | return SZ_ERROR_ARCHIVE; |
| @@ -265,6 +249,7 @@ static Z7_NO_INLINE SRes SzReadNumber32(CSzData *sd, UInt32 *value) | |||
| 265 | 249 | ||
| 266 | #define ReadID(sd, value) ReadNumber(sd, value) | 250 | #define ReadID(sd, value) ReadNumber(sd, value) |
| 267 | 251 | ||
| 252 | Z7_NO_INLINE | ||
| 268 | static SRes SkipData(CSzData *sd) | 253 | static SRes SkipData(CSzData *sd) |
| 269 | { | 254 | { |
| 270 | UInt64 size; | 255 | UInt64 size; |
| @@ -275,6 +260,7 @@ static SRes SkipData(CSzData *sd) | |||
| 275 | return SZ_OK; | 260 | return SZ_OK; |
| 276 | } | 261 | } |
| 277 | 262 | ||
| 263 | Z7_NO_INLINE | ||
| 278 | static SRes WaitId(CSzData *sd, UInt32 id) | 264 | static SRes WaitId(CSzData *sd, UInt32 id) |
| 279 | { | 265 | { |
| 280 | for (;;) | 266 | for (;;) |
| @@ -289,16 +275,8 @@ static SRes WaitId(CSzData *sd, UInt32 id) | |||
| 289 | } | 275 | } |
| 290 | } | 276 | } |
| 291 | 277 | ||
| 292 | static SRes RememberBitVector(CSzData *sd, size_t numItems, const Byte **v) | ||
| 293 | { | ||
| 294 | const size_t numBytes = (numItems + 7) >> 3; | ||
| 295 | if (numBytes > sd->Size) | ||
| 296 | return SZ_ERROR_ARCHIVE; | ||
| 297 | *v = sd->Data; | ||
| 298 | SKIP_DATA(sd, numBytes) | ||
| 299 | return SZ_OK; | ||
| 300 | } | ||
| 301 | 278 | ||
| 279 | Z7_NO_INLINE | ||
| 302 | static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) | 280 | static UInt32 CountDefinedBits(const Byte *bits, UInt32 numItems) |
| 303 | { | 281 | { |
| 304 | unsigned b = 0; | 282 | unsigned b = 0; |
| @@ -339,8 +317,8 @@ static Z7_NO_INLINE SRes ReadBitVector(CSzData *sd, size_t numItems, Byte **v, I | |||
| 339 | memset(v2, 0xFF, (size_t)numBytes); | 317 | memset(v2, 0xFF, (size_t)numBytes); |
| 340 | { | 318 | { |
| 341 | const unsigned numBits = (unsigned)numItems & 7; | 319 | const unsigned numBits = (unsigned)numItems & 7; |
| 342 | if (numBits != 0) | 320 | if (numBits) |
| 343 | v2[(size_t)numBytes - 1] = (Byte)((((UInt32)1 << numBits) - 1) << (8 - numBits)); | 321 | v2[(size_t)numBytes - 1] = (Byte)(0xff00u >> numBits); |
| 344 | } | 322 | } |
| 345 | return SZ_OK; | 323 | return SZ_OK; |
| 346 | } | 324 | } |
| @@ -348,31 +326,40 @@ static Z7_NO_INLINE SRes ReadBitVector(CSzData *sd, size_t numItems, Byte **v, I | |||
| 348 | static Z7_NO_INLINE SRes ReadUi32s(CSzData *sd2, size_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) | 326 | static Z7_NO_INLINE SRes ReadUi32s(CSzData *sd2, size_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) |
| 349 | { | 327 | { |
| 350 | size_t i; | 328 | size_t i; |
| 351 | CSzData sd; | 329 | const Byte *data; |
| 330 | size_t size; | ||
| 352 | UInt32 *vals; | 331 | UInt32 *vals; |
| 353 | const Byte *defs; | 332 | const Byte *defs; |
| 354 | MY_ALLOC_ZE(UInt32, crcs->Vals, numItems, alloc) | 333 | MY_ALLOC_ZE(UInt32, vals, numItems, alloc) |
| 355 | sd = *sd2; | 334 | crcs->Vals = vals; |
| 356 | defs = crcs->Defs; | 335 | defs = crcs->Defs; |
| 357 | vals = crcs->Vals; | 336 | data = sd2->Data; |
| 337 | size = sd2->Size; | ||
| 358 | for (i = 0; i < numItems; i++) | 338 | for (i = 0; i < numItems; i++) |
| 359 | if (SzBitArray_Check(defs, i)) | 339 | if (SzBitArray_Check(defs, i)) |
| 360 | { | 340 | { |
| 361 | SZ_READ_32(vals[i]) | 341 | if (size < 4) |
| 342 | return SZ_ERROR_ARCHIVE; | ||
| 343 | size -= 4; | ||
| 344 | vals[i] = GetUi32(data); | ||
| 345 | data += 4; | ||
| 362 | } | 346 | } |
| 363 | else | 347 | else |
| 364 | vals[i] = 0; | 348 | vals[i] = 0; |
| 365 | *sd2 = sd; | 349 | sd2->Data = data; |
| 350 | sd2->Size = size; | ||
| 366 | return SZ_OK; | 351 | return SZ_OK; |
| 367 | } | 352 | } |
| 368 | 353 | ||
| 369 | static SRes ReadBitUi32s(CSzData *sd, size_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) | 354 | static SRes ReadBitUi32s(CSzData *sd, size_t numItems, CSzBitUi32s *crcs, ISzAllocPtr alloc) |
| 370 | { | 355 | { |
| 371 | SzBitUi32s_Free(crcs, alloc); | 356 | if (crcs->Defs) |
| 357 | return SZ_ERROR_ARCHIVE; | ||
| 372 | RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc)) | 358 | RINOK(ReadBitVector(sd, numItems, &crcs->Defs, alloc)) |
| 373 | return ReadUi32s(sd, numItems, crcs, alloc); | 359 | return ReadUi32s(sd, numItems, crcs, alloc); |
| 374 | } | 360 | } |
| 375 | 361 | ||
| 362 | Z7_NO_INLINE | ||
| 376 | static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) | 363 | static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) |
| 377 | { | 364 | { |
| 378 | Byte allAreDefined; | 365 | Byte allAreDefined; |
| @@ -395,25 +382,26 @@ static SRes SkipBitUi32s(CSzData *sd, UInt32 numItems) | |||
| 395 | static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) | 382 | static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) |
| 396 | { | 383 | { |
| 397 | RINOK(SzReadNumber32(sd, &p->NumPackStreams)) | 384 | RINOK(SzReadNumber32(sd, &p->NumPackStreams)) |
| 398 | |||
| 399 | RINOK(WaitId(sd, k7zIdSize)) | 385 | RINOK(WaitId(sd, k7zIdSize)) |
| 400 | MY_ALLOC(UInt64, p->PackPositions, (size_t)p->NumPackStreams + 1, alloc) | ||
| 401 | { | 386 | { |
| 402 | UInt64 sum = 0; | 387 | UInt64 *packPositions; |
| 403 | UInt32 i; | 388 | UInt64 sum; |
| 404 | const UInt32 numPackStreams = p->NumPackStreams; | 389 | size_t num = (size_t)p->NumPackStreams + 1; |
| 405 | for (i = 0; i < numPackStreams; i++) | 390 | MY_ALLOC(UInt64, packPositions, num, alloc) |
| 391 | p->PackPositions = packPositions; | ||
| 392 | sum = 0; | ||
| 393 | for (;;) | ||
| 406 | { | 394 | { |
| 407 | UInt64 packSize; | 395 | UInt64 packSize; |
| 408 | p->PackPositions[i] = sum; | 396 | *packPositions++ = sum; |
| 397 | if (--num == 0) | ||
| 398 | break; | ||
| 409 | RINOK(ReadNumber(sd, &packSize)) | 399 | RINOK(ReadNumber(sd, &packSize)) |
| 410 | sum += packSize; | 400 | sum += packSize; |
| 411 | if (sum < packSize) | 401 | if (sum < packSize) |
| 412 | return SZ_ERROR_ARCHIVE; | 402 | return SZ_ERROR_ARCHIVE; |
| 413 | } | 403 | } |
| 414 | p->PackPositions[i] = sum; | ||
| 415 | } | 404 | } |
| 416 | |||
| 417 | for (;;) | 405 | for (;;) |
| 418 | { | 406 | { |
| 419 | UInt64 type; | 407 | UInt64 type; |
| @@ -430,85 +418,79 @@ static SRes ReadPackInfo(CSzAr *p, CSzData *sd, ISzAllocPtr alloc) | |||
| 430 | } | 418 | } |
| 431 | } | 419 | } |
| 432 | 420 | ||
| 433 | /* | ||
| 434 | static SRes SzReadSwitch(CSzData *sd) | ||
| 435 | { | ||
| 436 | Byte external; | ||
| 437 | RINOK(SzReadByte(sd, &external)); | ||
| 438 | return (external == 0) ? SZ_OK: SZ_ERROR_UNSUPPORTED; | ||
| 439 | } | ||
| 440 | */ | ||
| 441 | 421 | ||
| 442 | #define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) | 422 | #define k_NumCodersStreams_in_Folder_MAX (SZ_NUM_BONDS_IN_FOLDER_MAX + SZ_NUM_PACK_STREAMS_IN_FOLDER_MAX) |
| 443 | 423 | ||
| 444 | SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) | 424 | SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) |
| 445 | { | 425 | { |
| 446 | UInt32 numCoders, i; | 426 | UInt32 numCoders, i, numInStreams = 0; |
| 447 | UInt32 numInStreams = 0; | 427 | const Byte * const dataStart = sd->Data; |
| 448 | const Byte *dataStart = sd->Data; | ||
| 449 | 428 | ||
| 450 | f->NumCoders = 0; | 429 | // f->NumCoders = 0; |
| 451 | f->NumBonds = 0; | 430 | // f->NumBonds = 0; |
| 452 | f->NumPackStreams = 0; | 431 | // f->NumPackStreams = 0; |
| 453 | f->UnpackStream = 0; | 432 | f->UnpackStream = 0; |
| 454 | 433 | ||
| 455 | RINOK(SzReadNumber32(sd, &numCoders)) | 434 | RINOK(SzReadNumber32(sd, &numCoders)) |
| 456 | if (numCoders == 0 || numCoders > SZ_NUM_CODERS_IN_FOLDER_MAX) | 435 | if (numCoders == 0 || numCoders > SZ_NUM_CODERS_IN_FOLDER_MAX) |
| 457 | return SZ_ERROR_UNSUPPORTED; | 436 | return SZ_ERROR_UNSUPPORTED; |
| 437 | f->NumCoders = numCoders; | ||
| 458 | 438 | ||
| 459 | for (i = 0; i < numCoders; i++) | 439 | for (i = 0; i < numCoders; i++) |
| 460 | { | 440 | { |
| 461 | Byte mainByte; | 441 | Byte mainByte; |
| 462 | CSzCoderInfo *coder = f->Coders + i; | 442 | CSzCoderInfo *coder; |
| 463 | unsigned idSize, j; | ||
| 464 | UInt64 id; | ||
| 465 | |||
| 466 | SZ_READ_BYTE(mainByte) | ||
| 467 | if ((mainByte & 0xC0) != 0) | ||
| 468 | return SZ_ERROR_UNSUPPORTED; | ||
| 469 | |||
| 470 | idSize = (unsigned)(mainByte & 0xF); | ||
| 471 | if (idSize > sizeof(id)) | ||
| 472 | return SZ_ERROR_UNSUPPORTED; | ||
| 473 | if (idSize > sd->Size) | ||
| 474 | return SZ_ERROR_ARCHIVE; | ||
| 475 | id = 0; | ||
| 476 | for (j = 0; j < idSize; j++) | ||
| 477 | { | 443 | { |
| 478 | id = ((id << 8) | *sd->Data); | 444 | unsigned idSize, j; |
| 479 | sd->Data++; | 445 | UInt64 id; |
| 446 | const Byte *data; | ||
| 447 | |||
| 448 | if (!sd->Size) | ||
| 449 | return SZ_ERROR_ARCHIVE; | ||
| 480 | sd->Size--; | 450 | sd->Size--; |
| 451 | data = sd->Data; | ||
| 452 | mainByte = *data++; | ||
| 453 | if (mainByte & 0xC0) | ||
| 454 | return SZ_ERROR_UNSUPPORTED; | ||
| 455 | idSize = mainByte & 0xF; | ||
| 456 | if (idSize > sizeof(id)) | ||
| 457 | return SZ_ERROR_UNSUPPORTED; | ||
| 458 | if (idSize > sd->Size) | ||
| 459 | return SZ_ERROR_ARCHIVE; | ||
| 460 | sd->Size -= idSize; | ||
| 461 | id = 0; | ||
| 462 | for (j = 0; j < idSize; j++) | ||
| 463 | id = (id << 8) | *data++; | ||
| 464 | sd->Data = data; | ||
| 465 | if (id > (UInt32)0xFFFFFFFF) | ||
| 466 | return SZ_ERROR_UNSUPPORTED; | ||
| 467 | coder = f->Coders + i; | ||
| 468 | coder->MethodID = (UInt32)id; | ||
| 481 | } | 469 | } |
| 482 | if (id > (UInt32)0xFFFFFFFF) | ||
| 483 | return SZ_ERROR_UNSUPPORTED; | ||
| 484 | coder->MethodID = (UInt32)id; | ||
| 485 | 470 | ||
| 486 | coder->NumStreams = 1; | 471 | coder->NumStreams = 1; |
| 487 | coder->PropsOffset = 0; | 472 | coder->PropsOffset = 0; |
| 488 | coder->PropsSize = 0; | 473 | coder->PropsSize = 0; |
| 489 | 474 | ||
| 490 | if ((mainByte & 0x10) != 0) | 475 | if (mainByte & 0x10) |
| 491 | { | 476 | { |
| 492 | UInt32 numStreams; | 477 | UInt32 numStreams; |
| 493 | |||
| 494 | RINOK(SzReadNumber32(sd, &numStreams)) | 478 | RINOK(SzReadNumber32(sd, &numStreams)) |
| 495 | if (numStreams > k_NumCodersStreams_in_Folder_MAX) | 479 | if (numStreams > k_NumCodersStreams_in_Folder_MAX) |
| 496 | return SZ_ERROR_UNSUPPORTED; | 480 | return SZ_ERROR_UNSUPPORTED; |
| 497 | coder->NumStreams = (Byte)numStreams; | 481 | coder->NumStreams = (Byte)numStreams; |
| 498 | |||
| 499 | RINOK(SzReadNumber32(sd, &numStreams)) | 482 | RINOK(SzReadNumber32(sd, &numStreams)) |
| 500 | if (numStreams != 1) | 483 | if (numStreams != 1) |
| 501 | return SZ_ERROR_UNSUPPORTED; | 484 | return SZ_ERROR_UNSUPPORTED; |
| 502 | } | 485 | } |
| 503 | 486 | ||
| 504 | numInStreams += coder->NumStreams; | 487 | numInStreams += coder->NumStreams; |
| 505 | |||
| 506 | if (numInStreams > k_NumCodersStreams_in_Folder_MAX) | 488 | if (numInStreams > k_NumCodersStreams_in_Folder_MAX) |
| 507 | return SZ_ERROR_UNSUPPORTED; | 489 | return SZ_ERROR_UNSUPPORTED; |
| 508 | 490 | ||
| 509 | if ((mainByte & 0x20) != 0) | 491 | if (mainByte & 0x20) |
| 510 | { | 492 | { |
| 511 | UInt32 propsSize = 0; | 493 | UInt32 propsSize; |
| 512 | RINOK(SzReadNumber32(sd, &propsSize)) | 494 | RINOK(SzReadNumber32(sd, &propsSize)) |
| 513 | if (propsSize > sd->Size) | 495 | if (propsSize > sd->Size) |
| 514 | return SZ_ERROR_ARCHIVE; | 496 | return SZ_ERROR_ARCHIVE; |
| @@ -521,14 +503,6 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) | |||
| 521 | } | 503 | } |
| 522 | } | 504 | } |
| 523 | 505 | ||
| 524 | /* | ||
| 525 | if (numInStreams == 1 && numCoders == 1) | ||
| 526 | { | ||
| 527 | f->NumPackStreams = 1; | ||
| 528 | f->PackStreams[0] = 0; | ||
| 529 | } | ||
| 530 | else | ||
| 531 | */ | ||
| 532 | { | 506 | { |
| 533 | Byte streamUsed[k_NumCodersStreams_in_Folder_MAX]; | 507 | Byte streamUsed[k_NumCodersStreams_in_Folder_MAX]; |
| 534 | UInt32 numBonds, numPackStreams; | 508 | UInt32 numBonds, numPackStreams; |
| @@ -545,14 +519,13 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) | |||
| 545 | return SZ_ERROR_UNSUPPORTED; | 519 | return SZ_ERROR_UNSUPPORTED; |
| 546 | f->NumPackStreams = numPackStreams; | 520 | f->NumPackStreams = numPackStreams; |
| 547 | 521 | ||
| 548 | for (i = 0; i < numInStreams; i++) | 522 | for (i = 0; i < Z7_ARRAY_SIZE(streamUsed); i++) // numInStreams |
| 549 | streamUsed[i] = False; | 523 | streamUsed[i] = False; |
| 550 | 524 | ||
| 551 | if (numBonds != 0) | 525 | if (numBonds) |
| 552 | { | 526 | { |
| 553 | Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX]; | 527 | Byte coderUsed[SZ_NUM_CODERS_IN_FOLDER_MAX]; |
| 554 | 528 | for (i = 0; i < Z7_ARRAY_SIZE(coderUsed); i++) // numCoders | |
| 555 | for (i = 0; i < numCoders; i++) | ||
| 556 | coderUsed[i] = False; | 529 | coderUsed[i] = False; |
| 557 | 530 | ||
| 558 | for (i = 0; i < numBonds; i++) | 531 | for (i = 0; i < numBonds; i++) |
| @@ -570,24 +543,25 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) | |||
| 570 | coderUsed[bp->OutIndex] = True; | 543 | coderUsed[bp->OutIndex] = True; |
| 571 | } | 544 | } |
| 572 | 545 | ||
| 573 | for (i = 0; i < numCoders; i++) | 546 | for (i = 0;;) |
| 547 | { | ||
| 574 | if (!coderUsed[i]) | 548 | if (!coderUsed[i]) |
| 575 | { | ||
| 576 | f->UnpackStream = i; | ||
| 577 | break; | 549 | break; |
| 578 | } | 550 | if (++i == numCoders) |
| 579 | 551 | return SZ_ERROR_ARCHIVE; | |
| 580 | if (i == numCoders) | 552 | } |
| 581 | return SZ_ERROR_ARCHIVE; | 553 | f->UnpackStream = i; |
| 582 | } | 554 | } |
| 583 | 555 | ||
| 584 | if (numPackStreams == 1) | 556 | if (numPackStreams == 1) |
| 585 | { | 557 | { |
| 586 | for (i = 0; i < numInStreams; i++) | 558 | for (i = 0;; i++) |
| 559 | { | ||
| 560 | if (i == numInStreams) | ||
| 561 | return SZ_ERROR_ARCHIVE; | ||
| 587 | if (!streamUsed[i]) | 562 | if (!streamUsed[i]) |
| 588 | break; | 563 | break; |
| 589 | if (i == numInStreams) | 564 | } |
| 590 | return SZ_ERROR_ARCHIVE; | ||
| 591 | f->PackStreams[0] = i; | 565 | f->PackStreams[0] = i; |
| 592 | } | 566 | } |
| 593 | else | 567 | else |
| @@ -601,40 +575,30 @@ SRes SzGetNextFolderItem(CSzFolder *f, CSzData *sd) | |||
| 601 | f->PackStreams[i] = index; | 575 | f->PackStreams[i] = index; |
| 602 | } | 576 | } |
| 603 | } | 577 | } |
| 604 | |||
| 605 | f->NumCoders = numCoders; | ||
| 606 | |||
| 607 | return SZ_OK; | 578 | return SZ_OK; |
| 608 | } | 579 | } |
| 609 | 580 | ||
| 610 | 581 | ||
| 611 | static Z7_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) | 582 | static SRes SkipNumbers(CSzData *sd2, UInt32 num) |
| 612 | { | 583 | { |
| 613 | CSzData sd; | 584 | const Byte *data = sd2->Data; |
| 614 | sd = *sd2; | 585 | size_t size = sd2->Size; |
| 615 | for (; num != 0; num--) | 586 | for (; num != 0; num--) |
| 616 | { | 587 | { |
| 617 | Byte firstByte, mask; | 588 | unsigned firstByte; |
| 618 | unsigned i; | 589 | unsigned i; |
| 619 | SZ_READ_BYTE_2(firstByte) | 590 | if (size == 0) |
| 620 | if ((firstByte & 0x80) == 0) | ||
| 621 | continue; | ||
| 622 | if ((firstByte & 0x40) == 0) | ||
| 623 | { | ||
| 624 | if (sd.Size == 0) | ||
| 625 | return SZ_ERROR_ARCHIVE; | ||
| 626 | sd.Size--; | ||
| 627 | sd.Data++; | ||
| 628 | continue; | ||
| 629 | } | ||
| 630 | mask = 0x20; | ||
| 631 | for (i = 2; i < 8 && (firstByte & mask) != 0; i++) | ||
| 632 | mask >>= 1; | ||
| 633 | if (i > sd.Size) | ||
| 634 | return SZ_ERROR_ARCHIVE; | 591 | return SZ_ERROR_ARCHIVE; |
| 635 | SKIP_DATA2(sd, i) | 592 | firstByte = *data; |
| 593 | for (i = 1; firstByte & 0x80; i++) | ||
| 594 | firstByte <<= 1; | ||
| 595 | if (size < i) | ||
| 596 | return SZ_ERROR_ARCHIVE; | ||
| 597 | size -= i; | ||
| 598 | data += i; | ||
| 636 | } | 599 | } |
| 637 | *sd2 = sd; | 600 | sd2->Data = data; |
| 601 | sd2->Size = size; | ||
| 638 | return SZ_OK; | 602 | return SZ_OK; |
| 639 | } | 603 | } |
| 640 | 604 | ||
| @@ -642,15 +606,10 @@ static Z7_NO_INLINE SRes SkipNumbers(CSzData *sd2, UInt32 num) | |||
| 642 | #define k_Scan_NumCoders_MAX 64 | 606 | #define k_Scan_NumCoders_MAX 64 |
| 643 | #define k_Scan_NumCodersStreams_in_Folder_MAX 64 | 607 | #define k_Scan_NumCodersStreams_in_Folder_MAX 64 |
| 644 | 608 | ||
| 645 | 609 | static SRes ReadUnpackInfo(CSzAr *p, CSzData *sd2, const UInt32 numFoldersMax, | |
| 646 | static SRes ReadUnpackInfo(CSzAr *p, | 610 | const CBuf *tempBufs, UInt32 numTempBufs, ISzAllocPtr alloc) |
| 647 | CSzData *sd2, | ||
| 648 | UInt32 numFoldersMax, | ||
| 649 | const CBuf *tempBufs, UInt32 numTempBufs, | ||
| 650 | ISzAllocPtr alloc) | ||
| 651 | { | 611 | { |
| 652 | CSzData sd; | 612 | CSzData sd; |
| 653 | |||
| 654 | UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex; | 613 | UInt32 fo, numFolders, numCodersOutStreams, packStreamIndex; |
| 655 | const Byte *startBufPtr; | 614 | const Byte *startBufPtr; |
| 656 | Byte external; | 615 | Byte external; |
| @@ -742,15 +701,12 @@ static SRes ReadUnpackInfo(CSzAr *p, | |||
| 742 | { | 701 | { |
| 743 | Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX]; | 702 | Byte streamUsed[k_Scan_NumCodersStreams_in_Folder_MAX]; |
| 744 | Byte coderUsed[k_Scan_NumCoders_MAX]; | 703 | Byte coderUsed[k_Scan_NumCoders_MAX]; |
| 745 | |||
| 746 | UInt32 i; | 704 | UInt32 i; |
| 747 | const UInt32 numBonds = numCoders - 1; | 705 | const UInt32 numBonds = numCoders - 1; |
| 748 | if (numInStreams < numBonds) | 706 | if (numInStreams < numBonds) |
| 749 | return SZ_ERROR_ARCHIVE; | 707 | return SZ_ERROR_ARCHIVE; |
| 750 | |||
| 751 | if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX) | 708 | if (numInStreams > k_Scan_NumCodersStreams_in_Folder_MAX) |
| 752 | return SZ_ERROR_UNSUPPORTED; | 709 | return SZ_ERROR_UNSUPPORTED; |
| 753 | |||
| 754 | for (i = 0; i < numInStreams; i++) | 710 | for (i = 0; i < numInStreams; i++) |
| 755 | streamUsed[i] = False; | 711 | streamUsed[i] = False; |
| 756 | for (i = 0; i < numCoders; i++) | 712 | for (i = 0; i < numCoders; i++) |
| @@ -782,16 +738,15 @@ static SRes ReadUnpackInfo(CSzAr *p, | |||
| 782 | return SZ_ERROR_ARCHIVE; | 738 | return SZ_ERROR_ARCHIVE; |
| 783 | streamUsed[index] = True; | 739 | streamUsed[index] = True; |
| 784 | } | 740 | } |
| 785 | 741 | ||
| 786 | for (i = 0; i < numCoders; i++) | 742 | for (i = 0;;) |
| 743 | { | ||
| 787 | if (!coderUsed[i]) | 744 | if (!coderUsed[i]) |
| 788 | { | ||
| 789 | indexOfMainStream = i; | ||
| 790 | break; | 745 | break; |
| 791 | } | 746 | if (++i == numCoders) |
| 792 | 747 | return SZ_ERROR_ARCHIVE; | |
| 793 | if (i == numCoders) | 748 | } |
| 794 | return SZ_ERROR_ARCHIVE; | 749 | indexOfMainStream = i; |
| 795 | } | 750 | } |
| 796 | 751 | ||
| 797 | p->FoStartPackStreamIndex[fo] = packStreamIndex; | 752 | p->FoStartPackStreamIndex[fo] = packStreamIndex; |
| @@ -806,31 +761,38 @@ static SRes ReadUnpackInfo(CSzAr *p, | |||
| 806 | } | 761 | } |
| 807 | } | 762 | } |
| 808 | 763 | ||
| 764 | { | ||
| 765 | const size_t k_numCodersOutStreams_Limit = (size_t)1 << (sizeof(size_t) * 8 - 4); | ||
| 766 | if (numCodersOutStreams >= k_numCodersOutStreams_Limit) | ||
| 767 | return SZ_ERROR_UNSUPPORTED; | ||
| 768 | } | ||
| 809 | p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; | 769 | p->FoToCoderUnpackSizes[fo] = numCodersOutStreams; |
| 810 | 770 | p->FoStartPackStreamIndex[fo] = packStreamIndex; | |
| 811 | { | 771 | { |
| 812 | const size_t dataSize = (size_t)(sd.Data - startBufPtr); | 772 | const size_t dataSize = (size_t)(sd.Data - startBufPtr); |
| 813 | p->FoStartPackStreamIndex[fo] = packStreamIndex; | ||
| 814 | p->FoCodersOffsets[fo] = dataSize; | 773 | p->FoCodersOffsets[fo] = dataSize; |
| 815 | MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc) | 774 | MY_ALLOC_ZE_AND_CPY(p->CodersData, dataSize, startBufPtr, alloc) |
| 816 | } | 775 | } |
| 817 | 776 | ||
| 818 | if (external != 0) | 777 | if (external) |
| 819 | { | 778 | { |
| 820 | if (sd.Size != 0) | 779 | if (sd.Size) |
| 821 | return SZ_ERROR_ARCHIVE; | 780 | return SZ_ERROR_ARCHIVE; |
| 822 | sd = *sd2; | 781 | sd = *sd2; |
| 823 | } | 782 | } |
| 824 | 783 | ||
| 825 | RINOK(WaitId(&sd, k7zIdCodersUnpackSize)) | 784 | RINOK(WaitId(&sd, k7zIdCodersUnpackSize)) |
| 826 | |||
| 827 | MY_ALLOC_ZE(UInt64, p->CoderUnpackSizes, (size_t)numCodersOutStreams, alloc) | ||
| 828 | { | 785 | { |
| 829 | UInt32 i; | 786 | UInt64 *sizes; |
| 830 | for (i = 0; i < numCodersOutStreams; i++) | 787 | MY_ALLOC_ZE(UInt64, sizes, (size_t)numCodersOutStreams, alloc) |
| 831 | { | 788 | p->CoderUnpackSizes = sizes; |
| 832 | RINOK(ReadNumber(&sd, p->CoderUnpackSizes + i)) | 789 | if (numCodersOutStreams) |
| 833 | } | 790 | do |
| 791 | { | ||
| 792 | RINOK(ReadNumber(&sd, sizes)) | ||
| 793 | sizes++; | ||
| 794 | } | ||
| 795 | while (--numCodersOutStreams); | ||
| 834 | } | 796 | } |
| 835 | 797 | ||
| 836 | for (;;) | 798 | for (;;) |
| @@ -838,10 +800,7 @@ static SRes ReadUnpackInfo(CSzAr *p, | |||
| 838 | UInt64 type; | 800 | UInt64 type; |
| 839 | RINOK(ReadID(&sd, &type)) | 801 | RINOK(ReadID(&sd, &type)) |
| 840 | if (type == k7zIdEnd) | 802 | if (type == k7zIdEnd) |
| 841 | { | 803 | break; |
| 842 | *sd2 = sd; | ||
| 843 | return SZ_OK; | ||
| 844 | } | ||
| 845 | if (type == k7zIdCRC) | 804 | if (type == k7zIdCRC) |
| 846 | { | 805 | { |
| 847 | RINOK(ReadBitUi32s(&sd, numFolders, &p->FolderCRCs, alloc)) | 806 | RINOK(ReadBitUi32s(&sd, numFolders, &p->FolderCRCs, alloc)) |
| @@ -849,6 +808,8 @@ static SRes ReadUnpackInfo(CSzAr *p, | |||
| 849 | } | 808 | } |
| 850 | RINOK(SkipData(&sd)) | 809 | RINOK(SkipData(&sd)) |
| 851 | } | 810 | } |
| 811 | *sd2 = sd; | ||
| 812 | return SZ_OK; | ||
| 852 | } | 813 | } |
| 853 | 814 | ||
| 854 | 815 | ||
| @@ -868,12 +829,12 @@ typedef struct | |||
| 868 | } CSubStreamInfo; | 829 | } CSubStreamInfo; |
| 869 | 830 | ||
| 870 | 831 | ||
| 871 | static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) | 832 | static SRes ReadSubStreamsInfo(const CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) |
| 872 | { | 833 | { |
| 873 | UInt64 type = 0; | 834 | UInt64 type = 0; |
| 874 | UInt32 numSubDigests = 0; | ||
| 875 | const UInt32 numFolders = p->NumFolders; | 835 | const UInt32 numFolders = p->NumFolders; |
| 876 | UInt32 numUnpackStreams = numFolders; | 836 | UInt32 numUnpackStreams = numFolders; |
| 837 | UInt32 numSubDigests = numFolders; | ||
| 877 | UInt32 numUnpackSizesInData = 0; | 838 | UInt32 numUnpackSizesInData = 0; |
| 878 | 839 | ||
| 879 | for (;;) | 840 | for (;;) |
| @@ -882,6 +843,8 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) | |||
| 882 | if (type == k7zIdNumUnpackStream) | 843 | if (type == k7zIdNumUnpackStream) |
| 883 | { | 844 | { |
| 884 | UInt32 i; | 845 | UInt32 i; |
| 846 | if (ssi->sdNumSubStreams.Data) | ||
| 847 | return SZ_ERROR_UNSUPPORTED; | ||
| 885 | ssi->sdNumSubStreams.Data = sd->Data; | 848 | ssi->sdNumSubStreams.Data = sd->Data; |
| 886 | numUnpackStreams = 0; | 849 | numUnpackStreams = 0; |
| 887 | numSubDigests = 0; | 850 | numSubDigests = 0; |
| @@ -889,10 +852,10 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) | |||
| 889 | { | 852 | { |
| 890 | UInt32 numStreams; | 853 | UInt32 numStreams; |
| 891 | RINOK(SzReadNumber32(sd, &numStreams)) | 854 | RINOK(SzReadNumber32(sd, &numStreams)) |
| 892 | if (numUnpackStreams > numUnpackStreams + numStreams) | ||
| 893 | return SZ_ERROR_UNSUPPORTED; | ||
| 894 | numUnpackStreams += numStreams; | 855 | numUnpackStreams += numStreams; |
| 895 | if (numStreams != 0) | 856 | if (numUnpackStreams < numStreams) |
| 857 | return SZ_ERROR_UNSUPPORTED; | ||
| 858 | if (numStreams) | ||
| 896 | numUnpackSizesInData += (numStreams - 1); | 859 | numUnpackSizesInData += (numStreams - 1); |
| 897 | if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i)) | 860 | if (numStreams != 1 || !SzBitWithVals_Check(&p->FolderCRCs, i)) |
| 898 | numSubDigests += numStreams; | 861 | numSubDigests += numStreams; |
| @@ -905,12 +868,8 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) | |||
| 905 | RINOK(SkipData(sd)) | 868 | RINOK(SkipData(sd)) |
| 906 | } | 869 | } |
| 907 | 870 | ||
| 908 | if (!ssi->sdNumSubStreams.Data) | 871 | if (!ssi->sdNumSubStreams.Data && p->FolderCRCs.Defs) |
| 909 | { | 872 | numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders); |
| 910 | numSubDigests = numFolders; | ||
| 911 | if (p->FolderCRCs.Defs) | ||
| 912 | numSubDigests = numFolders - CountDefinedBits(p->FolderCRCs.Defs, numFolders); | ||
| 913 | } | ||
| 914 | 873 | ||
| 915 | ssi->NumTotalSubStreams = numUnpackStreams; | 874 | ssi->NumTotalSubStreams = numUnpackStreams; |
| 916 | ssi->NumSubDigests = numSubDigests; | 875 | ssi->NumSubDigests = numSubDigests; |
| @@ -929,6 +888,8 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) | |||
| 929 | return SZ_OK; | 888 | return SZ_OK; |
| 930 | if (type == k7zIdCRC) | 889 | if (type == k7zIdCRC) |
| 931 | { | 890 | { |
| 891 | if (ssi->sdCRCs.Data) | ||
| 892 | return SZ_ERROR_UNSUPPORTED; | ||
| 932 | ssi->sdCRCs.Data = sd->Data; | 893 | ssi->sdCRCs.Data = sd->Data; |
| 933 | RINOK(SkipBitUi32s(sd, numSubDigests)) | 894 | RINOK(SkipBitUi32s(sd, numSubDigests)) |
| 934 | ssi->sdCRCs.Size = (size_t)(sd->Data - ssi->sdCRCs.Data); | 895 | ssi->sdCRCs.Size = (size_t)(sd->Data - ssi->sdCRCs.Data); |
| @@ -941,9 +902,11 @@ static SRes ReadSubStreamsInfo(CSzAr *p, CSzData *sd, CSubStreamInfo *ssi) | |||
| 941 | } | 902 | } |
| 942 | } | 903 | } |
| 943 | 904 | ||
| 905 | |||
| 944 | static SRes SzReadStreamsInfo(CSzAr *p, | 906 | static SRes SzReadStreamsInfo(CSzAr *p, |
| 945 | CSzData *sd, | 907 | CSzData *sd, |
| 946 | UInt32 numFoldersMax, const CBuf *tempBufs, UInt32 numTempBufs, | 908 | const UInt32 numFoldersMax, |
| 909 | const CBuf * const tempBufs, const UInt32 numTempBufs, | ||
| 947 | UInt64 *dataOffset, | 910 | UInt64 *dataOffset, |
| 948 | CSubStreamInfo *ssi, | 911 | CSubStreamInfo *ssi, |
| 949 | ISzAllocPtr alloc) | 912 | ISzAllocPtr alloc) |
| @@ -985,12 +948,13 @@ static SRes SzReadStreamsInfo(CSzAr *p, | |||
| 985 | return (type == k7zIdEnd ? SZ_OK : SZ_ERROR_UNSUPPORTED); | 948 | return (type == k7zIdEnd ? SZ_OK : SZ_ERROR_UNSUPPORTED); |
| 986 | } | 949 | } |
| 987 | 950 | ||
| 951 | |||
| 988 | static SRes SzReadAndDecodePackedStreams( | 952 | static SRes SzReadAndDecodePackedStreams( |
| 989 | ILookInStreamPtr inStream, | 953 | ILookInStreamPtr inStream, |
| 990 | CSzData *sd, | 954 | CSzData *sd, |
| 991 | CBuf *tempBufs, | 955 | CBuf * const tempBufs, |
| 992 | UInt32 numFoldersMax, | 956 | const UInt32 numFoldersMax, |
| 993 | UInt64 baseOffset, | 957 | const UInt64 baseOffset, |
| 994 | CSzAr *p, | 958 | CSzAr *p, |
| 995 | ISzAllocPtr allocTemp) | 959 | ISzAllocPtr allocTemp) |
| 996 | { | 960 | { |
| @@ -1027,6 +991,7 @@ static SRes SzReadAndDecodePackedStreams( | |||
| 1027 | return SZ_OK; | 991 | return SZ_OK; |
| 1028 | } | 992 | } |
| 1029 | 993 | ||
| 994 | |||
| 1030 | // (size & 1) == 0 | 995 | // (size & 1) == 0 |
| 1031 | // (data) is aligned for 2-bytes | 996 | // (data) is aligned for 2-bytes |
| 1032 | static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets) | 997 | static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size_t *offsets) |
| @@ -1053,30 +1018,35 @@ static SRes SzReadFileNames(const Byte *data, size_t size, UInt32 numFiles, size | |||
| 1053 | return (p == lim) ? SZ_OK : SZ_ERROR_ARCHIVE; | 1018 | return (p == lim) ? SZ_OK : SZ_ERROR_ARCHIVE; |
| 1054 | } | 1019 | } |
| 1055 | 1020 | ||
| 1056 | static Z7_NO_INLINE SRes ReadTime(CSzBitUi64s *p, size_t num, | 1021 | |
| 1057 | CSzData *sd2, | 1022 | static SRes ReadTime(CSzBitUi64s *p, size_t num, CSzData *sd2, |
| 1058 | const CBuf *tempBufs, UInt32 numTempBufs, | 1023 | const CBuf *tempBufs, UInt32 numTempBufs, ISzAllocPtr alloc) |
| 1059 | ISzAllocPtr alloc) | ||
| 1060 | { | 1024 | { |
| 1061 | CSzData sd; | 1025 | const Byte *data; |
| 1026 | size_t size; | ||
| 1062 | size_t i; | 1027 | size_t i; |
| 1063 | CNtfsFileTime *vals; | 1028 | CNtfsFileTime *vals; |
| 1064 | Byte *defs; | 1029 | Byte *defs; |
| 1065 | Byte external; | 1030 | Byte external; |
| 1066 | 1031 | ||
| 1032 | if (p->Defs) | ||
| 1033 | return SZ_ERROR_ARCHIVE; | ||
| 1067 | RINOK(ReadBitVector(sd2, num, &p->Defs, alloc)) | 1034 | RINOK(ReadBitVector(sd2, num, &p->Defs, alloc)) |
| 1068 | 1035 | ||
| 1069 | SZ_READ_BYTE_SD(sd2, external) | 1036 | SZ_READ_BYTE_SD(sd2, external) |
| 1070 | if (external == 0) | 1037 | if (external == 0) |
| 1071 | sd = *sd2; | 1038 | { |
| 1039 | data = sd2->Data; | ||
| 1040 | size = sd2->Size; | ||
| 1041 | } | ||
| 1072 | else | 1042 | else |
| 1073 | { | 1043 | { |
| 1074 | UInt32 index; | 1044 | UInt32 index; |
| 1075 | RINOK(SzReadNumber32(sd2, &index)) | 1045 | RINOK(SzReadNumber32(sd2, &index)) |
| 1076 | if (index >= numTempBufs) | 1046 | if (index >= numTempBufs || sd2->Size) |
| 1077 | return SZ_ERROR_ARCHIVE; | 1047 | return SZ_ERROR_ARCHIVE; |
| 1078 | sd.Data = tempBufs[index].data; | 1048 | data = tempBufs[index].data; |
| 1079 | sd.Size = tempBufs[index].size; | 1049 | size = tempBufs[index].size; |
| 1080 | } | 1050 | } |
| 1081 | 1051 | ||
| 1082 | MY_ALLOC_ZE(CNtfsFileTime, p->Vals, num, alloc) | 1052 | MY_ALLOC_ZE(CNtfsFileTime, p->Vals, num, alloc) |
| @@ -1085,18 +1055,18 @@ static Z7_NO_INLINE SRes ReadTime(CSzBitUi64s *p, size_t num, | |||
| 1085 | for (i = 0; i < num; i++) | 1055 | for (i = 0; i < num; i++) |
| 1086 | if (SzBitArray_Check(defs, i)) | 1056 | if (SzBitArray_Check(defs, i)) |
| 1087 | { | 1057 | { |
| 1088 | if (sd.Size < 8) | 1058 | if (size < 8) |
| 1089 | return SZ_ERROR_ARCHIVE; | 1059 | return SZ_ERROR_ARCHIVE; |
| 1090 | vals[i].Low = GetUi32(sd.Data); | 1060 | size -= 8; |
| 1091 | vals[i].High = GetUi32(sd.Data + 4); | 1061 | vals[i].Low = GetUi32(data); |
| 1092 | SKIP_DATA2(sd, 8) | 1062 | vals[i].High = GetUi32(data + 4); |
| 1063 | data += 8; | ||
| 1093 | } | 1064 | } |
| 1094 | else | 1065 | else |
| 1095 | vals[i].High = vals[i].Low = 0; | 1066 | vals[i].High = vals[i].Low = 0; |
| 1096 | 1067 | ||
| 1097 | if (external == 0) | 1068 | if (size) |
| 1098 | *sd2 = sd; | 1069 | return SZ_ERROR_ARCHIVE; |
| 1099 | |||
| 1100 | return SZ_OK; | 1070 | return SZ_OK; |
| 1101 | } | 1071 | } |
| 1102 | 1072 | ||
| @@ -1104,16 +1074,11 @@ static Z7_NO_INLINE SRes ReadTime(CSzBitUi64s *p, size_t num, | |||
| 1104 | #define NUM_ADDITIONAL_STREAMS_MAX 8 | 1074 | #define NUM_ADDITIONAL_STREAMS_MAX 8 |
| 1105 | 1075 | ||
| 1106 | 1076 | ||
| 1107 | static SRes SzReadHeader2( | 1077 | static SRes SzReadHeader2(CSzArEx *p, CSzData *sd, ILookInStreamPtr inStream, |
| 1108 | CSzArEx *p, /* allocMain */ | 1078 | CBuf * const tempBufs, ISzAllocPtr allocMain, ISzAllocPtr allocTemp) |
| 1109 | CSzData *sd, | ||
| 1110 | ILookInStreamPtr inStream, | ||
| 1111 | CBuf *tempBufs, UInt32 *numTempBufs, | ||
| 1112 | ISzAllocPtr allocMain, | ||
| 1113 | ISzAllocPtr allocTemp | ||
| 1114 | ) | ||
| 1115 | { | 1079 | { |
| 1116 | CSubStreamInfo ssi; | 1080 | CSubStreamInfo ssi; |
| 1081 | UInt32 numTempBufs = 0; | ||
| 1117 | 1082 | ||
| 1118 | { | 1083 | { |
| 1119 | UInt64 type; | 1084 | UInt64 type; |
| @@ -1150,7 +1115,7 @@ static SRes SzReadHeader2( | |||
| 1150 | 1115 | ||
| 1151 | res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX, | 1116 | res = SzReadAndDecodePackedStreams(inStream, sd, tempBufs, NUM_ADDITIONAL_STREAMS_MAX, |
| 1152 | p->startPosAfterHeader, &tempAr, allocTemp); | 1117 | p->startPosAfterHeader, &tempAr, allocTemp); |
| 1153 | *numTempBufs = tempAr.NumFolders; | 1118 | numTempBufs = tempAr.NumFolders; |
| 1154 | SzAr_Free(&tempAr, allocTemp); | 1119 | SzAr_Free(&tempAr, allocTemp); |
| 1155 | 1120 | ||
| 1156 | if (res != SZ_OK) | 1121 | if (res != SZ_OK) |
| @@ -1160,24 +1125,21 @@ static SRes SzReadHeader2( | |||
| 1160 | 1125 | ||
| 1161 | if (type == k7zIdMainStreamsInfo) | 1126 | if (type == k7zIdMainStreamsInfo) |
| 1162 | { | 1127 | { |
| 1163 | RINOK(SzReadStreamsInfo(&p->db, sd, (UInt32)1 << 30, tempBufs, *numTempBufs, | 1128 | static const UInt32 k_numFoldersMax = (UInt32)1 << 30; |
| 1129 | RINOK(SzReadStreamsInfo(&p->db, sd, k_numFoldersMax, tempBufs, numTempBufs, | ||
| 1164 | &p->dataPos, &ssi, allocMain)) | 1130 | &p->dataPos, &ssi, allocMain)) |
| 1165 | p->dataPos += p->startPosAfterHeader; | 1131 | p->dataPos += p->startPosAfterHeader; |
| 1166 | RINOK(ReadID(sd, &type)) | 1132 | RINOK(ReadID(sd, &type)) |
| 1167 | } | 1133 | } |
| 1168 | 1134 | ||
| 1169 | if (type == k7zIdEnd) | 1135 | if (type == k7zIdEnd) |
| 1170 | { | ||
| 1171 | return SZ_OK; | 1136 | return SZ_OK; |
| 1172 | } | ||
| 1173 | |||
| 1174 | if (type != k7zIdFilesInfo) | 1137 | if (type != k7zIdFilesInfo) |
| 1175 | return SZ_ERROR_ARCHIVE; | 1138 | return SZ_ERROR_ARCHIVE; |
| 1176 | } | 1139 | } |
| 1177 | 1140 | ||
| 1178 | { | 1141 | { |
| 1179 | UInt32 numFiles = 0; | 1142 | UInt32 numFiles, numEmptyStreams = 0; |
| 1180 | UInt32 numEmptyStreams = 0; | ||
| 1181 | const Byte *emptyStreams = NULL; | 1143 | const Byte *emptyStreams = NULL; |
| 1182 | const Byte *emptyFiles = NULL; | 1144 | const Byte *emptyFiles = NULL; |
| 1183 | 1145 | ||
| @@ -1186,44 +1148,68 @@ static SRes SzReadHeader2( | |||
| 1186 | 1148 | ||
| 1187 | for (;;) | 1149 | for (;;) |
| 1188 | { | 1150 | { |
| 1151 | CSzData sdSwitch; | ||
| 1189 | UInt64 type; | 1152 | UInt64 type; |
| 1190 | UInt64 size; | ||
| 1191 | RINOK(ReadID(sd, &type)) | 1153 | RINOK(ReadID(sd, &type)) |
| 1192 | if (type == k7zIdEnd) | 1154 | if (type == k7zIdEnd) |
| 1193 | break; | 1155 | break; |
| 1194 | RINOK(ReadNumber(sd, &size)) | ||
| 1195 | if (size > sd->Size) | ||
| 1196 | return SZ_ERROR_ARCHIVE; | ||
| 1197 | |||
| 1198 | if (type >= ((UInt32)1 << 8)) | ||
| 1199 | { | 1156 | { |
| 1157 | UInt64 size; | ||
| 1158 | RINOK(ReadNumber(sd, &size)) | ||
| 1159 | if (size > sd->Size) | ||
| 1160 | return SZ_ERROR_ARCHIVE; | ||
| 1161 | sdSwitch.Data = sd->Data; | ||
| 1162 | sdSwitch.Size = (size_t)size; | ||
| 1200 | SKIP_DATA(sd, size) | 1163 | SKIP_DATA(sd, size) |
| 1201 | } | 1164 | } |
| 1202 | else switch ((unsigned)type) | 1165 | if (type >= 64) |
| 1166 | continue; | ||
| 1167 | |||
| 1168 | switch ((unsigned)type) | ||
| 1203 | { | 1169 | { |
| 1170 | case k7zIdEmptyStream: | ||
| 1171 | { | ||
| 1172 | if (emptyStreams || emptyFiles) | ||
| 1173 | return SZ_ERROR_ARCHIVE; | ||
| 1174 | if ((numFiles + 7) >> 3 != sdSwitch.Size) | ||
| 1175 | return SZ_ERROR_ARCHIVE; | ||
| 1176 | emptyStreams = sdSwitch.Data; | ||
| 1177 | numEmptyStreams = CountDefinedBits(emptyStreams, numFiles); | ||
| 1178 | break; | ||
| 1179 | } | ||
| 1180 | |||
| 1181 | case k7zIdEmptyFile: | ||
| 1182 | { | ||
| 1183 | if (emptyFiles) | ||
| 1184 | return SZ_ERROR_ARCHIVE; | ||
| 1185 | if ((numEmptyStreams + 7) >> 3 != sdSwitch.Size) | ||
| 1186 | return SZ_ERROR_ARCHIVE; | ||
| 1187 | emptyFiles = sdSwitch.Data; | ||
| 1188 | break; | ||
| 1189 | } | ||
| 1190 | |||
| 1204 | case k7zIdName: | 1191 | case k7zIdName: |
| 1205 | { | 1192 | { |
| 1206 | size_t namesSize; | 1193 | size_t namesSize; |
| 1207 | const Byte *namesData; | 1194 | const Byte *namesData; |
| 1208 | Byte external; | 1195 | Byte external; |
| 1209 | 1196 | if (p->FileNameOffsets) | |
| 1210 | SZ_READ_BYTE(external) | 1197 | return SZ_ERROR_ARCHIVE; |
| 1198 | SZ_READ_BYTE_SD(&sdSwitch, external) | ||
| 1211 | if (external == 0) | 1199 | if (external == 0) |
| 1212 | { | 1200 | { |
| 1213 | namesSize = (size_t)size - 1; | 1201 | namesData = sdSwitch.Data; |
| 1214 | namesData = sd->Data; | 1202 | namesSize = sdSwitch.Size; |
| 1215 | SKIP_DATA(sd, namesSize) | ||
| 1216 | } | 1203 | } |
| 1217 | else | 1204 | else |
| 1218 | { | 1205 | { |
| 1219 | UInt32 index; | 1206 | UInt32 index; |
| 1220 | RINOK(SzReadNumber32(sd, &index)) | 1207 | RINOK(SzReadNumber32(&sdSwitch, &index)) |
| 1221 | if (index >= *numTempBufs) | 1208 | if (index >= numTempBufs || sdSwitch.Size) |
| 1222 | return SZ_ERROR_ARCHIVE; | 1209 | return SZ_ERROR_ARCHIVE; |
| 1223 | namesData = (tempBufs)[index].data; | 1210 | namesData = tempBufs[index].data; |
| 1224 | namesSize = (tempBufs)[index].size; | 1211 | namesSize = tempBufs[index].size; |
| 1225 | } | 1212 | } |
| 1226 | |||
| 1227 | if (namesSize & 1) | 1213 | if (namesSize & 1) |
| 1228 | return SZ_ERROR_ARCHIVE; | 1214 | return SZ_ERROR_ARCHIVE; |
| 1229 | MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain) | 1215 | MY_ALLOC(size_t, p->FileNameOffsets, numFiles + 1, allocMain) |
| @@ -1231,58 +1217,38 @@ static SRes SzReadHeader2( | |||
| 1231 | RINOK(SzReadFileNames(p->FileNames, namesSize, numFiles, p->FileNameOffsets)) | 1217 | RINOK(SzReadFileNames(p->FileNames, namesSize, numFiles, p->FileNameOffsets)) |
| 1232 | break; | 1218 | break; |
| 1233 | } | 1219 | } |
| 1234 | case k7zIdEmptyStream: | 1220 | |
| 1235 | { | ||
| 1236 | RINOK(RememberBitVector(sd, numFiles, &emptyStreams)) | ||
| 1237 | numEmptyStreams = CountDefinedBits(emptyStreams, numFiles); | ||
| 1238 | emptyFiles = NULL; | ||
| 1239 | break; | ||
| 1240 | } | ||
| 1241 | case k7zIdEmptyFile: | ||
| 1242 | { | ||
| 1243 | RINOK(RememberBitVector(sd, numEmptyStreams, &emptyFiles)) | ||
| 1244 | break; | ||
| 1245 | } | ||
| 1246 | case k7zIdWinAttrib: | 1221 | case k7zIdWinAttrib: |
| 1247 | { | 1222 | { |
| 1248 | Byte external; | 1223 | Byte external; |
| 1249 | CSzData sdSwitch; | 1224 | if (p->Attribs.Defs) |
| 1250 | CSzData *sdPtr; | 1225 | return SZ_ERROR_ARCHIVE; |
| 1251 | SzBitUi32s_Free(&p->Attribs, allocMain); | 1226 | RINOK(ReadBitVector(&sdSwitch, numFiles, &p->Attribs.Defs, allocMain)) |
| 1252 | RINOK(ReadBitVector(sd, numFiles, &p->Attribs.Defs, allocMain)) | 1227 | SZ_READ_BYTE_SD(&sdSwitch, external) |
| 1253 | 1228 | if (external) | |
| 1254 | SZ_READ_BYTE(external) | ||
| 1255 | if (external == 0) | ||
| 1256 | sdPtr = sd; | ||
| 1257 | else | ||
| 1258 | { | 1229 | { |
| 1259 | UInt32 index; | 1230 | UInt32 index; |
| 1260 | RINOK(SzReadNumber32(sd, &index)) | 1231 | RINOK(SzReadNumber32(&sdSwitch, &index)) |
| 1261 | if (index >= *numTempBufs) | 1232 | if (index >= numTempBufs || sdSwitch.Size) |
| 1262 | return SZ_ERROR_ARCHIVE; | 1233 | return SZ_ERROR_ARCHIVE; |
| 1263 | sdSwitch.Data = (tempBufs)[index].data; | 1234 | sdSwitch.Data = tempBufs[index].data; |
| 1264 | sdSwitch.Size = (tempBufs)[index].size; | 1235 | sdSwitch.Size = tempBufs[index].size; |
| 1265 | sdPtr = &sdSwitch; | ||
| 1266 | } | 1236 | } |
| 1267 | RINOK(ReadUi32s(sdPtr, numFiles, &p->Attribs, allocMain)) | 1237 | RINOK(ReadUi32s(&sdSwitch, numFiles, &p->Attribs, allocMain)) |
| 1238 | if (sdSwitch.Size) | ||
| 1239 | return SZ_ERROR_ARCHIVE; | ||
| 1268 | break; | 1240 | break; |
| 1269 | } | 1241 | } |
| 1270 | /* | 1242 | |
| 1271 | case k7zParent: | 1243 | case k7zIdMTime: |
| 1244 | case k7zIdCTime: | ||
| 1272 | { | 1245 | { |
| 1273 | SzBitUi32s_Free(&p->Parents, allocMain); | 1246 | RINOK(ReadTime((unsigned)type == k7zIdMTime ? &p->MTime: &p->CTime, |
| 1274 | RINOK(ReadBitVector(sd, numFiles, &p->Parents.Defs, allocMain)); | 1247 | numFiles, &sdSwitch, tempBufs, numTempBufs, allocMain)) |
| 1275 | RINOK(SzReadSwitch(sd)); | ||
| 1276 | RINOK(ReadUi32s(sd, numFiles, &p->Parents, allocMain)); | ||
| 1277 | break; | 1248 | break; |
| 1278 | } | 1249 | } |
| 1279 | */ | 1250 | |
| 1280 | case k7zIdMTime: RINOK(ReadTime(&p->MTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)) break; | 1251 | default: break; |
| 1281 | case k7zIdCTime: RINOK(ReadTime(&p->CTime, numFiles, sd, tempBufs, *numTempBufs, allocMain)) break; | ||
| 1282 | default: | ||
| 1283 | { | ||
| 1284 | SKIP_DATA(sd, size) | ||
| 1285 | } | ||
| 1286 | } | 1252 | } |
| 1287 | } | 1253 | } |
| 1288 | 1254 | ||
| @@ -1481,25 +1447,19 @@ static SRes SzReadHeader( | |||
| 1481 | ISzAllocPtr allocTemp) | 1447 | ISzAllocPtr allocTemp) |
| 1482 | { | 1448 | { |
| 1483 | UInt32 i; | 1449 | UInt32 i; |
| 1484 | UInt32 numTempBufs = 0; | ||
| 1485 | SRes res; | 1450 | SRes res; |
| 1486 | CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX]; | 1451 | CBuf tempBufs[NUM_ADDITIONAL_STREAMS_MAX]; |
| 1487 | 1452 | ||
| 1488 | for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) | 1453 | for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) |
| 1489 | Buf_Init(tempBufs + i); | 1454 | Buf_Init(tempBufs + i); |
| 1490 | 1455 | ||
| 1491 | res = SzReadHeader2(p, sd, inStream, | 1456 | res = SzReadHeader2(p, sd, inStream, tempBufs, allocMain, allocTemp); |
| 1492 | tempBufs, &numTempBufs, | ||
| 1493 | allocMain, allocTemp); | ||
| 1494 | 1457 | ||
| 1495 | for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) | 1458 | for (i = 0; i < NUM_ADDITIONAL_STREAMS_MAX; i++) |
| 1496 | Buf_Free(tempBufs + i, allocTemp); | 1459 | Buf_Free(tempBufs + i, allocTemp); |
| 1497 | 1460 | ||
| 1498 | RINOK(res) | 1461 | if (res == SZ_OK && sd->Size != 0) |
| 1499 | 1462 | return SZ_ERROR_ARCHIVE; | |
| 1500 | if (sd->Size != 0) | ||
| 1501 | return SZ_ERROR_FAIL; | ||
| 1502 | |||
| 1503 | return res; | 1463 | return res; |
| 1504 | } | 1464 | } |
| 1505 | 1465 | ||
| @@ -1510,53 +1470,52 @@ static SRes SzArEx_Open2( | |||
| 1510 | ISzAllocPtr allocTemp) | 1470 | ISzAllocPtr allocTemp) |
| 1511 | { | 1471 | { |
| 1512 | Byte header[k7zStartHeaderSize]; | 1472 | Byte header[k7zStartHeaderSize]; |
| 1513 | Int64 startArcPos; | 1473 | Int64 startPosAfterHeader; |
| 1514 | UInt64 nextHeaderOffset, nextHeaderSize; | 1474 | UInt64 nextHeaderOffset, nextHeaderSize; |
| 1515 | size_t nextHeaderSizeT; | 1475 | size_t nextHeaderSizeT; |
| 1516 | UInt32 nextHeaderCRC; | 1476 | UInt32 nextHeaderCRC; |
| 1517 | CBuf buf; | 1477 | CBuf buf; |
| 1518 | SRes res; | 1478 | SRes res; |
| 1519 | 1479 | ||
| 1520 | startArcPos = 0; | ||
| 1521 | RINOK(ILookInStream_Seek(inStream, &startArcPos, SZ_SEEK_CUR)) | ||
| 1522 | |||
| 1523 | RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)) | 1480 | RINOK(LookInStream_Read2(inStream, header, k7zStartHeaderSize, SZ_ERROR_NO_ARCHIVE)) |
| 1524 | 1481 | startPosAfterHeader = 0; // k7zStartHeaderSize | |
| 1525 | if (!TestSignatureCandidate(header)) | 1482 | RINOK(ILookInStream_Seek(inStream, &startPosAfterHeader, SZ_SEEK_CUR)) |
| 1526 | return SZ_ERROR_NO_ARCHIVE; | 1483 | p->startPosAfterHeader = (UInt64)startPosAfterHeader; |
| 1527 | if (header[6] != k7zMajorVersion) | 1484 | { |
| 1528 | return SZ_ERROR_UNSUPPORTED; | 1485 | unsigned i; |
| 1486 | for (i = 0; i < k7zSignatureSize; i++) | ||
| 1487 | if (header[i] != k7zSignature[i]) | ||
| 1488 | return SZ_ERROR_NO_ARCHIVE; | ||
| 1489 | if (header[6] != 0) // k7zMajorVersion | ||
| 1490 | return SZ_ERROR_UNSUPPORTED; | ||
| 1491 | } | ||
| 1492 | if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) | ||
| 1493 | return SZ_ERROR_CRC; | ||
| 1529 | 1494 | ||
| 1530 | nextHeaderOffset = GetUi64(header + 12); | 1495 | nextHeaderOffset = GetUi64(header + 12); |
| 1531 | nextHeaderSize = GetUi64(header + 20); | 1496 | nextHeaderSize = GetUi64(header + 20); |
| 1532 | nextHeaderCRC = GetUi32(header + 28); | 1497 | nextHeaderCRC = GetUi32(header + 28); |
| 1533 | 1498 | ||
| 1534 | p->startPosAfterHeader = (UInt64)startArcPos + k7zStartHeaderSize; | ||
| 1535 | |||
| 1536 | if (CrcCalc(header + 12, 20) != GetUi32(header + 8)) | ||
| 1537 | return SZ_ERROR_CRC; | ||
| 1538 | |||
| 1539 | p->db.RangeLimit = nextHeaderOffset; | 1499 | p->db.RangeLimit = nextHeaderOffset; |
| 1540 | 1500 | if (nextHeaderOffset >= (UInt64)1 << 62 || | |
| 1501 | nextHeaderSize >= (UInt64)1 << 48) | ||
| 1502 | return SZ_ERROR_NO_ARCHIVE; | ||
| 1541 | nextHeaderSizeT = (size_t)nextHeaderSize; | 1503 | nextHeaderSizeT = (size_t)nextHeaderSize; |
| 1542 | if (nextHeaderSizeT != nextHeaderSize) | 1504 | if (nextHeaderSizeT != nextHeaderSize) |
| 1543 | return SZ_ERROR_MEM; | 1505 | return SZ_ERROR_MEM; |
| 1544 | if (nextHeaderSizeT == 0) | 1506 | if (nextHeaderSizeT == 0) |
| 1507 | { | ||
| 1508 | if (nextHeaderOffset != 0 || nextHeaderCRC != 0) | ||
| 1509 | return SZ_ERROR_NO_ARCHIVE; | ||
| 1545 | return SZ_OK; | 1510 | return SZ_OK; |
| 1546 | if (nextHeaderOffset > nextHeaderOffset + nextHeaderSize || | 1511 | } |
| 1547 | nextHeaderOffset > nextHeaderOffset + nextHeaderSize + k7zStartHeaderSize) | ||
| 1548 | return SZ_ERROR_NO_ARCHIVE; | ||
| 1549 | |||
| 1550 | { | 1512 | { |
| 1551 | Int64 pos = 0; | 1513 | Int64 pos = 0; |
| 1552 | RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END)) | 1514 | RINOK(ILookInStream_Seek(inStream, &pos, SZ_SEEK_END)) |
| 1553 | if ((UInt64)pos < (UInt64)startArcPos + nextHeaderOffset || | 1515 | if ((UInt64)(pos - startPosAfterHeader) < nextHeaderOffset + nextHeaderSize) |
| 1554 | (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset || | ||
| 1555 | (UInt64)pos < (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset + nextHeaderSize) | ||
| 1556 | return SZ_ERROR_INPUT_EOF; | 1516 | return SZ_ERROR_INPUT_EOF; |
| 1557 | } | 1517 | } |
| 1558 | 1518 | RINOK(LookInStream_SeekTo(inStream, (UInt64)startPosAfterHeader + nextHeaderOffset)) | |
| 1559 | RINOK(LookInStream_SeekTo(inStream, (UInt64)startArcPos + k7zStartHeaderSize + nextHeaderOffset)) | ||
| 1560 | 1519 | ||
| 1561 | if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp)) | 1520 | if (!Buf_Create(&buf, nextHeaderSizeT, allocTemp)) |
| 1562 | return SZ_ERROR_MEM; | 1521 | return SZ_ERROR_MEM; |
| @@ -1720,61 +1679,23 @@ SRes SzArEx_Extract( | |||
| 1720 | 1679 | ||
| 1721 | size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) | 1680 | size_t SzArEx_GetFileNameUtf16(const CSzArEx *p, size_t fileIndex, UInt16 *dest) |
| 1722 | { | 1681 | { |
| 1723 | const size_t offs = p->FileNameOffsets[fileIndex]; | 1682 | const size_t * const offsets = p->FileNameOffsets; |
| 1724 | const size_t len = p->FileNameOffsets[fileIndex + 1] - offs; | 1683 | if (!offsets) |
| 1725 | if (dest != 0) | ||
| 1726 | { | 1684 | { |
| 1727 | size_t i; | 1685 | if (dest) |
| 1728 | const Byte *src = p->FileNames + offs * 2; | 1686 | *dest = 0; |
| 1729 | for (i = 0; i < len; i++) | ||
| 1730 | dest[i] = GetUi16(src + i * 2); | ||
| 1731 | } | ||
| 1732 | return len; | ||
| 1733 | } | ||
| 1734 | |||
| 1735 | /* | ||
| 1736 | size_t SzArEx_GetFullNameLen(const CSzArEx *p, size_t fileIndex) | ||
| 1737 | { | ||
| 1738 | size_t len; | ||
| 1739 | if (!p->FileNameOffsets) | ||
| 1740 | return 1; | 1687 | return 1; |
| 1741 | len = 0; | ||
| 1742 | for (;;) | ||
| 1743 | { | ||
| 1744 | UInt32 parent = (UInt32)(Int32)-1; | ||
| 1745 | len += p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; | ||
| 1746 | if SzBitWithVals_Check(&p->Parents, fileIndex) | ||
| 1747 | parent = p->Parents.Vals[fileIndex]; | ||
| 1748 | if (parent == (UInt32)(Int32)-1) | ||
| 1749 | return len; | ||
| 1750 | fileIndex = parent; | ||
| 1751 | } | 1688 | } |
| 1752 | } | ||
| 1753 | |||
| 1754 | UInt16 *SzArEx_GetFullNameUtf16_Back(const CSzArEx *p, size_t fileIndex, UInt16 *dest) | ||
| 1755 | { | ||
| 1756 | BoolInt needSlash; | ||
| 1757 | if (!p->FileNameOffsets) | ||
| 1758 | { | ||
| 1759 | *(--dest) = 0; | ||
| 1760 | return dest; | ||
| 1761 | } | ||
| 1762 | needSlash = False; | ||
| 1763 | for (;;) | ||
| 1764 | { | 1689 | { |
| 1765 | UInt32 parent = (UInt32)(Int32)-1; | 1690 | const size_t offs = offsets[fileIndex]; |
| 1766 | size_t curLen = p->FileNameOffsets[fileIndex + 1] - p->FileNameOffsets[fileIndex]; | 1691 | const size_t len = offsets[fileIndex + 1] - offs; |
| 1767 | SzArEx_GetFileNameUtf16(p, fileIndex, dest - curLen); | 1692 | if (dest) |
| 1768 | if (needSlash) | 1693 | { |
| 1769 | *(dest - 1) = '/'; | 1694 | size_t i; |
| 1770 | needSlash = True; | 1695 | const Byte *src = p->FileNames + offs * 2; |
| 1771 | dest -= curLen; | 1696 | for (i = 0; i < len; i++) |
| 1772 | 1697 | dest[i] = GetUi16a(src + i * 2); | |
| 1773 | if SzBitWithVals_Check(&p->Parents, fileIndex) | 1698 | } |
| 1774 | parent = p->Parents.Vals[fileIndex]; | 1699 | return len; |
| 1775 | if (parent == (UInt32)(Int32)-1) | ||
| 1776 | return dest; | ||
| 1777 | fileIndex = parent; | ||
| 1778 | } | 1700 | } |
| 1779 | } | 1701 | } |
| 1780 | */ | ||
diff --git a/C/7zVersion.h b/C/7zVersion.h index 387a91c..50ccebb 100644 --- a/C/7zVersion.h +++ b/C/7zVersion.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | #define MY_VER_MAJOR 26 | 1 | #define MY_VER_MAJOR 26 |
| 2 | #define MY_VER_MINOR 1 | 2 | #define MY_VER_MINOR 2 |
| 3 | #define MY_VER_BUILD 0 | 3 | #define MY_VER_BUILD 0 |
| 4 | #define MY_VERSION_NUMBERS "26.01" | 4 | #define MY_VERSION_NUMBERS "26.02" |
| 5 | #define MY_VERSION MY_VERSION_NUMBERS | 5 | #define MY_VERSION MY_VERSION_NUMBERS |
| 6 | 6 | ||
| 7 | #ifdef MY_CPU_NAME | 7 | #ifdef MY_CPU_NAME |
| @@ -10,7 +10,7 @@ | |||
| 10 | #define MY_VERSION_CPU MY_VERSION | 10 | #define MY_VERSION_CPU MY_VERSION |
| 11 | #endif | 11 | #endif |
| 12 | 12 | ||
| 13 | #define MY_DATE "2026-04-27" | 13 | #define MY_DATE "2026-06-25" |
| 14 | #undef MY_COPYRIGHT | 14 | #undef MY_COPYRIGHT |
| 15 | #undef MY_VERSION_COPYRIGHT_DATE | 15 | #undef MY_VERSION_COPYRIGHT_DATE |
| 16 | #define MY_AUTHOR_NAME "Igor Pavlov" | 16 | #define MY_AUTHOR_NAME "Igor Pavlov" |
diff --git a/C/Compiler.h b/C/Compiler.h index a3577b2..c06b883 100644 --- a/C/Compiler.h +++ b/C/Compiler.h | |||
| @@ -76,6 +76,11 @@ | |||
| 76 | #pragma GCC diagnostic ignored "-Wreserved-identifier" | 76 | #pragma GCC diagnostic ignored "-Wreserved-identifier" |
| 77 | #endif | 77 | #endif |
| 78 | 78 | ||
| 79 | #if __clang_major__ >= 22 | ||
| 80 | // for "StdAfx.h" and "Precomp.h" | ||
| 81 | #pragma GCC diagnostic ignored "-Wshadow-header" | ||
| 82 | #endif | ||
| 83 | |||
| 79 | #endif // __clang__ | 84 | #endif // __clang__ |
| 80 | 85 | ||
| 81 | #if defined(__clang__) && __clang_major__ >= 16 | 86 | #if defined(__clang__) && __clang_major__ >= 16 |
diff --git a/C/DllSecur.c b/C/DllSecur.c index bbbfc0a..d385259 100644 --- a/C/DllSecur.c +++ b/C/DllSecur.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* DllSecur.c -- DLL loading security | 1 | /* DllSecur.c -- DLL loading security |
| 2 | 2023-12-03 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -67,7 +67,7 @@ void LoadSecurityDlls(void) | |||
| 67 | // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? | 67 | // at Vista (ver 6.0) : CoCreateInstance(CLSID_ShellLink, ...) doesn't work after SetDefaultDllDirectories() : Check it ??? |
| 68 | IF_NON_VISTA_SET_DLL_DIRS_AND_RETURN | 68 | IF_NON_VISTA_SET_DLL_DIRS_AND_RETURN |
| 69 | { | 69 | { |
| 70 | wchar_t buf[MAX_PATH + 100]; | 70 | WCHAR buf[MAX_PATH + 100]; |
| 71 | const char *dll; | 71 | const char *dll; |
| 72 | unsigned pos = GetSystemDirectoryW(buf, MAX_PATH + 2); | 72 | unsigned pos = GetSystemDirectoryW(buf, MAX_PATH + 2); |
| 73 | if (pos == 0 || pos > MAX_PATH) | 73 | if (pos == 0 || pos > MAX_PATH) |
| @@ -76,7 +76,7 @@ void LoadSecurityDlls(void) | |||
| 76 | buf[pos++] = '\\'; | 76 | buf[pos++] = '\\'; |
| 77 | for (dll = g_Dlls; *dll != 0;) | 77 | for (dll = g_Dlls; *dll != 0;) |
| 78 | { | 78 | { |
| 79 | wchar_t *dest = &buf[pos]; | 79 | WCHAR *dest = &buf[pos]; |
| 80 | for (;;) | 80 | for (;;) |
| 81 | { | 81 | { |
| 82 | const char c = *dll++; | 82 | const char c = *dll++; |
| @@ -1,5 +1,5 @@ | |||
| 1 | /* MtDec.c -- Multi-thread Decoder | 1 | /* MtDec.c -- Multi-thread Decoder |
| 2 | 2024-02-20 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -22,7 +22,7 @@ | |||
| 22 | #define PRF(x) | 22 | #define PRF(x) |
| 23 | #endif | 23 | #endif |
| 24 | 24 | ||
| 25 | #define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) | 25 | #define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d);) |
| 26 | 26 | ||
| 27 | void MtProgress_Init(CMtProgress *p, ICompressProgressPtr progress) | 27 | void MtProgress_Init(CMtProgress *p, ICompressProgressPtr progress) |
| 28 | { | 28 | { |
diff --git a/C/Util/7z/7zMain.c b/C/Util/7z/7zMain.c index 7048b66..300c363 100644 --- a/C/Util/7z/7zMain.c +++ b/C/Util/7z/7zMain.c | |||
| @@ -960,7 +960,12 @@ int Z7_CDECL main(int numargs, char *args[]) | |||
| 960 | if (listCommand == 0 && isDir && !fullPaths) | 960 | if (listCommand == 0 && isDir && !fullPaths) |
| 961 | continue; | 961 | continue; |
| 962 | len = SzArEx_GetFileNameUtf16(&db, i, NULL); | 962 | len = SzArEx_GetFileNameUtf16(&db, i, NULL); |
| 963 | // len = SzArEx_GetFullNameLen(&db, i); | 963 | |
| 964 | if (len > (1u << 20)) | ||
| 965 | { | ||
| 966 | res = SZ_ERROR_UNSUPPORTED; | ||
| 967 | break; | ||
| 968 | } | ||
| 964 | 969 | ||
| 965 | if (len > tempSize) | 970 | if (len > tempSize) |
| 966 | { | 971 | { |
diff --git a/C/Util/7zipInstall/7zipInstall.c b/C/Util/7zipInstall/7zipInstall.c index 7d8e8c4..ce30732 100644 --- a/C/Util/7zipInstall/7zipInstall.c +++ b/C/Util/7zipInstall/7zipInstall.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* 7zipInstall.c - 7-Zip Installer | 1 | /* 7zipInstall.c - 7-Zip Installer |
| 2 | 2024-04-05 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -142,7 +142,7 @@ static WCHAR path[MAX_PATH * 2 + 40]; | |||
| 142 | 142 | ||
| 143 | 143 | ||
| 144 | 144 | ||
| 145 | static void CpyAscii(wchar_t *dest, const char *s) | 145 | static void CpyAscii(WCHAR *dest, const char *s) |
| 146 | { | 146 | { |
| 147 | for (;;) | 147 | for (;;) |
| 148 | { | 148 | { |
| @@ -153,13 +153,13 @@ static void CpyAscii(wchar_t *dest, const char *s) | |||
| 153 | } | 153 | } |
| 154 | } | 154 | } |
| 155 | 155 | ||
| 156 | static void CatAscii(wchar_t *dest, const char *s) | 156 | static void CatAscii(WCHAR *dest, const char *s) |
| 157 | { | 157 | { |
| 158 | dest += wcslen(dest); | 158 | dest += wcslen(dest); |
| 159 | CpyAscii(dest, s); | 159 | CpyAscii(dest, s); |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | static void PrintErrorMessage(const char *s1, const wchar_t *s2) | 162 | static void PrintErrorMessage(const char *s1, const WCHAR *s2) |
| 163 | { | 163 | { |
| 164 | WCHAR m[MAX_PATH + 512]; | 164 | WCHAR m[MAX_PATH + 512]; |
| 165 | m[0] = 0; | 165 | m[0] = 0; |
| @@ -196,7 +196,7 @@ static DWORD GetFileVersion(LPCWSTR s) | |||
| 196 | 196 | ||
| 197 | if (!g_version_dll_hModule) | 197 | if (!g_version_dll_hModule) |
| 198 | { | 198 | { |
| 199 | wchar_t buf[MAX_PATH + 100]; | 199 | WCHAR buf[MAX_PATH + 100]; |
| 200 | { | 200 | { |
| 201 | unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); | 201 | unsigned len = GetSystemDirectoryW(buf, MAX_PATH + 2); |
| 202 | if (len == 0 || len > MAX_PATH) | 202 | if (len == 0 || len > MAX_PATH) |
| @@ -255,13 +255,13 @@ static WRes MyCreateDir(LPCWSTR name) | |||
| 255 | #define IS_LETTER_CHAR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) | 255 | #define IS_LETTER_CHAR(c) (((c) >= 'a' && (c) <= 'z') || ((c) >= 'A' && (c) <= 'Z')) |
| 256 | #define IS_DRIVE_PATH(s) (IS_LETTER_CHAR(s[0]) && s[1] == ':' && IS_SEPAR(s[2])) | 256 | #define IS_DRIVE_PATH(s) (IS_LETTER_CHAR(s[0]) && s[1] == ':' && IS_SEPAR(s[2])) |
| 257 | 257 | ||
| 258 | static int ReverseFind_PathSepar(const wchar_t *s) | 258 | static int ReverseFind_PathSepar(const WCHAR *s) |
| 259 | { | 259 | { |
| 260 | int separ = -1; | 260 | int separ = -1; |
| 261 | int i; | 261 | int i; |
| 262 | for (i = 0;; i++) | 262 | for (i = 0;; i++) |
| 263 | { | 263 | { |
| 264 | wchar_t c = s[i]; | 264 | WCHAR c = s[i]; |
| 265 | if (c == 0) | 265 | if (c == 0) |
| 266 | return separ; | 266 | return separ; |
| 267 | if (IS_SEPAR(c)) | 267 | if (IS_SEPAR(c)) |
| @@ -566,7 +566,7 @@ static void NormalizePrefix(WCHAR *s) | |||
| 566 | 566 | ||
| 567 | for (;; i++) | 567 | for (;; i++) |
| 568 | { | 568 | { |
| 569 | const wchar_t c = s[i]; | 569 | const WCHAR c = s[i]; |
| 570 | if (c == 0) | 570 | if (c == 0) |
| 571 | break; | 571 | break; |
| 572 | if (c == '/') | 572 | if (c == '/') |
| @@ -587,10 +587,10 @@ static char MyCharLower_Ascii(char c) | |||
| 587 | return c; | 587 | return c; |
| 588 | } | 588 | } |
| 589 | 589 | ||
| 590 | static wchar_t MyWCharLower_Ascii(wchar_t c) | 590 | static WCHAR MyWCharLower_Ascii(WCHAR c) |
| 591 | { | 591 | { |
| 592 | if (c >= 'A' && c <= 'Z') | 592 | if (c >= 'A' && c <= 'Z') |
| 593 | return (wchar_t)(c + 0x20); | 593 | return (WCHAR)(c + 0x20); |
| 594 | return c; | 594 | return c; |
| 595 | } | 595 | } |
| 596 | 596 | ||
| @@ -976,13 +976,13 @@ static void WriteShellEx(void) | |||
| 976 | } | 976 | } |
| 977 | 977 | ||
| 978 | 978 | ||
| 979 | static const wchar_t *GetCmdParam(const wchar_t *s) | 979 | static const WCHAR *GetCmdParam(const WCHAR *s) |
| 980 | { | 980 | { |
| 981 | unsigned pos = 0; | 981 | unsigned pos = 0; |
| 982 | BoolInt quoteMode = False; | 982 | BoolInt quoteMode = False; |
| 983 | for (;; s++) | 983 | for (;; s++) |
| 984 | { | 984 | { |
| 985 | wchar_t c = *s; | 985 | WCHAR c = *s; |
| 986 | if (c == 0 || (c == L' ' && !quoteMode)) | 986 | if (c == 0 || (c == L' ' && !quoteMode)) |
| 987 | break; | 987 | break; |
| 988 | if (c == L'\"') | 988 | if (c == L'\"') |
| @@ -999,12 +999,12 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
| 999 | } | 999 | } |
| 1000 | 1000 | ||
| 1001 | 1001 | ||
| 1002 | static void RemoveQuotes(wchar_t *s) | 1002 | static void RemoveQuotes(WCHAR *s) |
| 1003 | { | 1003 | { |
| 1004 | const wchar_t *src = s; | 1004 | const WCHAR *src = s; |
| 1005 | for (;;) | 1005 | for (;;) |
| 1006 | { | 1006 | { |
| 1007 | wchar_t c = *src++; | 1007 | WCHAR c = *src++; |
| 1008 | if (c == '\"') | 1008 | if (c == '\"') |
| 1009 | continue; | 1009 | continue; |
| 1010 | *s++ = c; | 1010 | *s++ = c; |
| @@ -1039,7 +1039,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1039 | CrcGenerateTable(); | 1039 | CrcGenerateTable(); |
| 1040 | 1040 | ||
| 1041 | { | 1041 | { |
| 1042 | const wchar_t *s = GetCommandLineW(); | 1042 | const WCHAR *s = GetCommandLineW(); |
| 1043 | 1043 | ||
| 1044 | #ifndef UNDER_CE | 1044 | #ifndef UNDER_CE |
| 1045 | s = GetCmdParam(s); | 1045 | s = GetCmdParam(s); |
| @@ -1048,7 +1048,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1048 | for (;;) | 1048 | for (;;) |
| 1049 | { | 1049 | { |
| 1050 | { | 1050 | { |
| 1051 | const wchar_t c = *s; | 1051 | const WCHAR c = *s; |
| 1052 | if (c == 0) | 1052 | if (c == 0) |
| 1053 | break; | 1053 | break; |
| 1054 | if (c == ' ') | 1054 | if (c == ' ') |
| @@ -1059,7 +1059,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1059 | } | 1059 | } |
| 1060 | 1060 | ||
| 1061 | { | 1061 | { |
| 1062 | const wchar_t *s2 = GetCmdParam(s); | 1062 | const WCHAR *s2 = GetCmdParam(s); |
| 1063 | BoolInt error = True; | 1063 | BoolInt error = True; |
| 1064 | if (cmd[0] == '/') | 1064 | if (cmd[0] == '/') |
| 1065 | { | 1065 | { |
| @@ -1315,7 +1315,7 @@ if (res == SZ_OK) | |||
| 1315 | 1315 | ||
| 1316 | for (;;) | 1316 | for (;;) |
| 1317 | { | 1317 | { |
| 1318 | const wchar_t c = path[i++]; | 1318 | const WCHAR c = path[i++]; |
| 1319 | if (c == 0) | 1319 | if (c == 0) |
| 1320 | break; | 1320 | break; |
| 1321 | if (c != ' ') | 1321 | if (c != ' ') |
diff --git a/C/Util/7zipUninstall/7zipUninstall.c b/C/Util/7zipUninstall/7zipUninstall.c index e7051e2..2c1333b 100644 --- a/C/Util/7zipUninstall/7zipUninstall.c +++ b/C/Util/7zipUninstall/7zipUninstall.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* 7zipUninstall.c - 7-Zip Uninstaller | 1 | /* 7zipUninstall.c - 7-Zip Uninstaller |
| 2 | 2024-03-21 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -147,7 +147,7 @@ static LPCWSTR const kUninstallExe = L"Uninstall.exe"; | |||
| 147 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) | 147 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) |
| 148 | 148 | ||
| 149 | 149 | ||
| 150 | static void CpyAscii(wchar_t *dest, const char *s) | 150 | static void CpyAscii(WCHAR *dest, const char *s) |
| 151 | { | 151 | { |
| 152 | for (;;) | 152 | for (;;) |
| 153 | { | 153 | { |
| @@ -158,13 +158,13 @@ static void CpyAscii(wchar_t *dest, const char *s) | |||
| 158 | } | 158 | } |
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | static void CatAscii(wchar_t *dest, const char *s) | 161 | static void CatAscii(WCHAR *dest, const char *s) |
| 162 | { | 162 | { |
| 163 | dest += wcslen(dest); | 163 | dest += wcslen(dest); |
| 164 | CpyAscii(dest, s); | 164 | CpyAscii(dest, s); |
| 165 | } | 165 | } |
| 166 | 166 | ||
| 167 | static void PrintErrorMessage(const char *s1, const wchar_t *s2) | 167 | static void PrintErrorMessage(const char *s1, const WCHAR *s2) |
| 168 | { | 168 | { |
| 169 | WCHAR m[MAX_PATH + 512]; | 169 | WCHAR m[MAX_PATH + 512]; |
| 170 | m[0] = 0; | 170 | m[0] = 0; |
| @@ -183,12 +183,12 @@ static void PrintErrorMessage(const char *s1, const wchar_t *s2) | |||
| 183 | } | 183 | } |
| 184 | 184 | ||
| 185 | 185 | ||
| 186 | static BoolInt AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2) | 186 | static BoolInt AreStringsEqual_NoCase(const WCHAR *s1, const WCHAR *s2) |
| 187 | { | 187 | { |
| 188 | for (;;) | 188 | for (;;) |
| 189 | { | 189 | { |
| 190 | wchar_t c1 = *s1++; | 190 | WCHAR c1 = *s1++; |
| 191 | wchar_t c2 = *s2++; | 191 | WCHAR c2 = *s2++; |
| 192 | if (c1 != c2 && MAKE_CHAR_UPPER(c1) != MAKE_CHAR_UPPER(c2)) | 192 | if (c1 != c2 && MAKE_CHAR_UPPER(c1) != MAKE_CHAR_UPPER(c2)) |
| 193 | return False; | 193 | return False; |
| 194 | if (c2 == 0) | 194 | if (c2 == 0) |
| @@ -196,12 +196,12 @@ static BoolInt AreStringsEqual_NoCase(const wchar_t *s1, const wchar_t *s2) | |||
| 196 | } | 196 | } |
| 197 | } | 197 | } |
| 198 | 198 | ||
| 199 | static BoolInt IsString1PrefixedByString2_NoCase(const wchar_t *s1, const wchar_t *s2) | 199 | static BoolInt IsString1PrefixedByString2_NoCase(const WCHAR *s1, const WCHAR *s2) |
| 200 | { | 200 | { |
| 201 | for (;;) | 201 | for (;;) |
| 202 | { | 202 | { |
| 203 | wchar_t c1; | 203 | WCHAR c1; |
| 204 | const wchar_t c2 = *s2++; | 204 | const WCHAR c2 = *s2++; |
| 205 | if (c2 == 0) | 205 | if (c2 == 0) |
| 206 | return True; | 206 | return True; |
| 207 | c1 = *s1++; | 207 | c1 = *s1++; |
| @@ -446,7 +446,7 @@ static LPCWSTR const k_AppPaths_7zFm = L"Software\\Microsoft\\Windows\\CurrentVe | |||
| 446 | static LPCWSTR const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip"; | 446 | static LPCWSTR const k_Uninstall_7zip = k_REG_Uninstall L"7-Zip"; |
| 447 | 447 | ||
| 448 | 448 | ||
| 449 | static void RemoveQuotes(wchar_t *s) | 449 | static void RemoveQuotes(WCHAR *s) |
| 450 | { | 450 | { |
| 451 | const size_t len = wcslen(s); | 451 | const size_t len = wcslen(s); |
| 452 | size_t i; | 452 | size_t i; |
| @@ -457,7 +457,7 @@ static void RemoveQuotes(wchar_t *s) | |||
| 457 | s[len - 2] = 0; | 457 | s[len - 2] = 0; |
| 458 | } | 458 | } |
| 459 | 459 | ||
| 460 | static BoolInt AreEqual_Path_PrefixName(const wchar_t *s, const wchar_t *prefix, const wchar_t *name) | 460 | static BoolInt AreEqual_Path_PrefixName(const WCHAR *s, const WCHAR *prefix, const WCHAR *name) |
| 461 | { | 461 | { |
| 462 | if (!IsString1PrefixedByString2_NoCase(s, prefix)) | 462 | if (!IsString1PrefixedByString2_NoCase(s, prefix)) |
| 463 | return False; | 463 | return False; |
| @@ -558,13 +558,13 @@ static void WriteCLSID(void) | |||
| 558 | } | 558 | } |
| 559 | 559 | ||
| 560 | 560 | ||
| 561 | static const wchar_t *GetCmdParam(const wchar_t *s) | 561 | static const WCHAR *GetCmdParam(const WCHAR *s) |
| 562 | { | 562 | { |
| 563 | unsigned pos = 0; | 563 | unsigned pos = 0; |
| 564 | BoolInt quoteMode = False; | 564 | BoolInt quoteMode = False; |
| 565 | for (;; s++) | 565 | for (;; s++) |
| 566 | { | 566 | { |
| 567 | const wchar_t c = *s; | 567 | const WCHAR c = *s; |
| 568 | if (c == 0 || (c == L' ' && !quoteMode)) | 568 | if (c == 0 || (c == L' ' && !quoteMode)) |
| 569 | break; | 569 | break; |
| 570 | if (c == L'\"') | 570 | if (c == L'\"') |
| @@ -581,12 +581,12 @@ static const wchar_t *GetCmdParam(const wchar_t *s) | |||
| 581 | } | 581 | } |
| 582 | 582 | ||
| 583 | /* | 583 | /* |
| 584 | static void RemoveQuotes(wchar_t *s) | 584 | static void RemoveQuotes(WCHAR *s) |
| 585 | { | 585 | { |
| 586 | const wchar_t *src = s; | 586 | const WCHAR *src = s; |
| 587 | for (;;) | 587 | for (;;) |
| 588 | { | 588 | { |
| 589 | wchar_t c = *src++; | 589 | WCHAR c = *src++; |
| 590 | if (c == '\"') | 590 | if (c == '\"') |
| 591 | continue; | 591 | continue; |
| 592 | *s++ = c; | 592 | *s++ = c; |
| @@ -618,11 +618,11 @@ static BOOL RemoveFileAfterReboot(void) | |||
| 618 | 618 | ||
| 619 | // #define IS_LIMIT_CHAR(c) (c == 0 || c == ' ') | 619 | // #define IS_LIMIT_CHAR(c) (c == 0 || c == ' ') |
| 620 | 620 | ||
| 621 | static BoolInt IsThereSpace(const wchar_t *s) | 621 | static BoolInt IsThereSpace(const WCHAR *s) |
| 622 | { | 622 | { |
| 623 | for (;;) | 623 | for (;;) |
| 624 | { | 624 | { |
| 625 | const wchar_t c = *s++; | 625 | const WCHAR c = *s++; |
| 626 | if (c == 0) | 626 | if (c == 0) |
| 627 | return False; | 627 | return False; |
| 628 | if (c == ' ') | 628 | if (c == ' ') |
| @@ -630,7 +630,7 @@ static BoolInt IsThereSpace(const wchar_t *s) | |||
| 630 | } | 630 | } |
| 631 | } | 631 | } |
| 632 | 632 | ||
| 633 | static void AddPathParam(wchar_t *dest, const wchar_t *src) | 633 | static void AddPathParam(WCHAR *dest, const WCHAR *src) |
| 634 | { | 634 | { |
| 635 | const BoolInt needQuote = IsThereSpace(src); | 635 | const BoolInt needQuote = IsThereSpace(src); |
| 636 | if (needQuote) | 636 | if (needQuote) |
| @@ -937,7 +937,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 937 | #endif | 937 | #endif |
| 938 | lpCmdLine, int nCmdShow) | 938 | lpCmdLine, int nCmdShow) |
| 939 | { | 939 | { |
| 940 | const wchar_t *cmdParams; | 940 | const WCHAR *cmdParams; |
| 941 | BoolInt useTemp = True; | 941 | BoolInt useTemp = True; |
| 942 | 942 | ||
| 943 | UNUSED_VAR(hPrevInstance) | 943 | UNUSED_VAR(hPrevInstance) |
| @@ -957,7 +957,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 957 | #endif | 957 | #endif |
| 958 | 958 | ||
| 959 | { | 959 | { |
| 960 | const wchar_t *s = GetCommandLineW(); | 960 | const WCHAR *s = GetCommandLineW(); |
| 961 | 961 | ||
| 962 | #ifndef UNDER_CE | 962 | #ifndef UNDER_CE |
| 963 | s = GetCmdParam(s); | 963 | s = GetCmdParam(s); |
| @@ -968,7 +968,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 968 | for (;;) | 968 | for (;;) |
| 969 | { | 969 | { |
| 970 | { | 970 | { |
| 971 | wchar_t c = *s; | 971 | WCHAR c = *s; |
| 972 | if (c == 0) | 972 | if (c == 0) |
| 973 | break; | 973 | break; |
| 974 | if (c == ' ') | 974 | if (c == ' ') |
| @@ -979,7 +979,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 979 | } | 979 | } |
| 980 | 980 | ||
| 981 | { | 981 | { |
| 982 | const wchar_t *s2 = GetCmdParam(s); | 982 | const WCHAR *s2 = GetCmdParam(s); |
| 983 | BoolInt error = True; | 983 | BoolInt error = True; |
| 984 | if (cmd[0] == '/') | 984 | if (cmd[0] == '/') |
| 985 | { | 985 | { |
| @@ -1022,7 +1022,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1022 | } | 1022 | } |
| 1023 | 1023 | ||
| 1024 | { | 1024 | { |
| 1025 | wchar_t *name; | 1025 | WCHAR *name; |
| 1026 | const DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); | 1026 | const DWORD len = GetModuleFileNameW(NULL, modulePath, MAX_PATH); |
| 1027 | if (len == 0 || len > MAX_PATH) | 1027 | if (len == 0 || len > MAX_PATH) |
| 1028 | return 1; | 1028 | return 1; |
| @@ -1031,10 +1031,10 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1031 | wcscpy(modulePrefix, modulePath); | 1031 | wcscpy(modulePrefix, modulePath); |
| 1032 | 1032 | ||
| 1033 | { | 1033 | { |
| 1034 | wchar_t *s = modulePrefix; | 1034 | WCHAR *s = modulePrefix; |
| 1035 | for (;;) | 1035 | for (;;) |
| 1036 | { | 1036 | { |
| 1037 | const wchar_t c = *s++; | 1037 | const WCHAR c = *s++; |
| 1038 | if (c == 0) | 1038 | if (c == 0) |
| 1039 | break; | 1039 | break; |
| 1040 | if (c == WCHAR_PATH_SEPARATOR) | 1040 | if (c == WCHAR_PATH_SEPARATOR) |
| @@ -1079,14 +1079,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 1079 | CpyAscii(path + pathLen, "7z"); | 1079 | CpyAscii(path + pathLen, "7z"); |
| 1080 | 1080 | ||
| 1081 | { | 1081 | { |
| 1082 | wchar_t *s = path + wcslen(path); | 1082 | WCHAR *s = path + wcslen(path); |
| 1083 | UInt32 value = d; | 1083 | UInt32 value = d; |
| 1084 | unsigned k; | 1084 | unsigned k; |
| 1085 | for (k = 0; k < 8; k++) | 1085 | for (k = 0; k < 8; k++) |
| 1086 | { | 1086 | { |
| 1087 | const unsigned t = value & 0xF; | 1087 | const unsigned t = value & 0xF; |
| 1088 | value >>= 4; | 1088 | value >>= 4; |
| 1089 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); | 1089 | s[7 - k] = (WCHAR)((t < 10) ? ('0' + t) : ('A' + (t - 10))); |
| 1090 | } | 1090 | } |
| 1091 | s[k] = 0; | 1091 | s[k] = 0; |
| 1092 | } | 1092 | } |
diff --git a/C/Util/SfxSetup/SfxSetup.c b/C/Util/SfxSetup/SfxSetup.c index 9b5c1f9..344aa73 100644 --- a/C/Util/SfxSetup/SfxSetup.c +++ b/C/Util/SfxSetup/SfxSetup.c | |||
| @@ -1,5 +1,5 @@ | |||
| 1 | /* SfxSetup.c - 7z SFX Setup | 1 | /* SfxSetup.c - 7z SFX Setup |
| 2 | 2024-01-24 : Igor Pavlov : Public domain */ | 2 | : Igor Pavlov : Public domain */ |
| 3 | 3 | ||
| 4 | #include "Precomp.h" | 4 | #include "Precomp.h" |
| 5 | 5 | ||
| @@ -54,7 +54,7 @@ static const char * const kNames[] = | |||
| 54 | , "start" | 54 | , "start" |
| 55 | }; | 55 | }; |
| 56 | 56 | ||
| 57 | static unsigned FindExt(const wchar_t *s, unsigned *extLen) | 57 | static unsigned FindExt(const WCHAR *s, unsigned *extLen) |
| 58 | { | 58 | { |
| 59 | unsigned len = (unsigned)wcslen(s); | 59 | unsigned len = (unsigned)wcslen(s); |
| 60 | unsigned i; | 60 | unsigned i; |
| @@ -72,7 +72,7 @@ static unsigned FindExt(const wchar_t *s, unsigned *extLen) | |||
| 72 | 72 | ||
| 73 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) | 73 | #define MAKE_CHAR_UPPER(c) ((((c) >= 'a' && (c) <= 'z') ? (c) - 0x20 : (c))) |
| 74 | 74 | ||
| 75 | static unsigned FindItem(const char * const *items, unsigned num, const wchar_t *s, unsigned len) | 75 | static unsigned FindItem(const char * const *items, unsigned num, const WCHAR *s, unsigned len) |
| 76 | { | 76 | { |
| 77 | unsigned i; | 77 | unsigned i; |
| 78 | for (i = 0; i < num; i++) | 78 | for (i = 0; i < num; i++) |
| @@ -268,7 +268,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 268 | #endif | 268 | #endif |
| 269 | size_t pathLen; | 269 | size_t pathLen; |
| 270 | DWORD winRes; | 270 | DWORD winRes; |
| 271 | const wchar_t *cmdLineParams; | 271 | const WCHAR *cmdLineParams; |
| 272 | const char *errorMessage = NULL; | 272 | const char *errorMessage = NULL; |
| 273 | BoolInt useShellExecute = True; | 273 | BoolInt useShellExecute = True; |
| 274 | DWORD exitCode = 0; | 274 | DWORD exitCode = 0; |
| @@ -306,7 +306,7 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 306 | BoolInt quoteMode = False; | 306 | BoolInt quoteMode = False; |
| 307 | for (;; cmdLineParams++) | 307 | for (;; cmdLineParams++) |
| 308 | { | 308 | { |
| 309 | const wchar_t c = *cmdLineParams; | 309 | const WCHAR c = *cmdLineParams; |
| 310 | if (c == L'\"') | 310 | if (c == L'\"') |
| 311 | quoteMode = !quoteMode; | 311 | quoteMode = !quoteMode; |
| 312 | else if (c == 0 || (c == L' ' && !quoteMode)) | 312 | else if (c == 0 || (c == L' ' && !quoteMode)) |
| @@ -335,14 +335,14 @@ int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, | |||
| 335 | wcscpy(path + pathLen, L"7z"); | 335 | wcscpy(path + pathLen, L"7z"); |
| 336 | 336 | ||
| 337 | { | 337 | { |
| 338 | wchar_t *s = path + wcslen(path); | 338 | WCHAR *s = path + wcslen(path); |
| 339 | UInt32 value = d; | 339 | UInt32 value = d; |
| 340 | unsigned k; | 340 | unsigned k; |
| 341 | for (k = 0; k < 8; k++) | 341 | for (k = 0; k < 8; k++) |
| 342 | { | 342 | { |
| 343 | const unsigned t = value & 0xF; | 343 | const unsigned t = value & 0xF; |
| 344 | value >>= 4; | 344 | value >>= 4; |
| 345 | s[7 - k] = (wchar_t)((t < 10) ? ('0' + t) : ('A' + (t - 10))); | 345 | s[7 - k] = (WCHAR)((t < 10) ? ('0' + t) : ('A' + (t - 10))); |
| 346 | } | 346 | } |
| 347 | s[k] = '\0'; | 347 | s[k] = '\0'; |
| 348 | } | 348 | } |
| @@ -25,8 +25,8 @@ | |||
| 25 | #define PRF(x) | 25 | #define PRF(x) |
| 26 | #endif | 26 | #endif |
| 27 | 27 | ||
| 28 | #define PRF_STR(s) PRF(printf("\n" s "\n")) | 28 | #define PRF_STR(s) PRF(printf("\n" s "\n");) |
| 29 | #define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d)) | 29 | #define PRF_STR_INT(s, d) PRF(printf("\n" s " %d\n", (unsigned)d);) |
| 30 | 30 | ||
| 31 | #include <stdlib.h> | 31 | #include <stdlib.h> |
| 32 | #include <string.h> | 32 | #include <string.h> |
| @@ -574,7 +574,7 @@ static SRes MixCoder_ResetFromMethod(CMixCoder *p, unsigned coderIndex, UInt64 m | |||
| 574 | output (status) can be : | 574 | output (status) can be : |
| 575 | CODER_STATUS_NOT_FINISHED | 575 | CODER_STATUS_NOT_FINISHED |
| 576 | CODER_STATUS_FINISHED_WITH_MARK | 576 | CODER_STATUS_FINISHED_WITH_MARK |
| 577 | CODER_STATUS_NEEDS_MORE_INPUT - not implemented still | 577 | CODER_STATUS_NEEDS_MORE_INPUT |
| 578 | */ | 578 | */ |
| 579 | 579 | ||
| 580 | static SRes MixCoder_Code(CMixCoder *p, | 580 | static SRes MixCoder_Code(CMixCoder *p, |
| @@ -582,8 +582,8 @@ static SRes MixCoder_Code(CMixCoder *p, | |||
| 582 | const Byte *src, SizeT *srcLen, int srcWasFinished, | 582 | const Byte *src, SizeT *srcLen, int srcWasFinished, |
| 583 | ECoderFinishMode finishMode) | 583 | ECoderFinishMode finishMode) |
| 584 | { | 584 | { |
| 585 | SizeT destLenOrig = *destLen; | 585 | const SizeT destLenOrig = *destLen; |
| 586 | SizeT srcLenOrig = *srcLen; | 586 | const SizeT srcLenOrig = *srcLen; |
| 587 | 587 | ||
| 588 | *destLen = 0; | 588 | *destLen = 0; |
| 589 | *srcLen = 0; | 589 | *srcLen = 0; |
| @@ -597,39 +597,26 @@ static SRes MixCoder_Code(CMixCoder *p, | |||
| 597 | if (p->outBuf) | 597 | if (p->outBuf) |
| 598 | { | 598 | { |
| 599 | SRes res; | 599 | SRes res; |
| 600 | SizeT destLen2, srcLen2; | 600 | SizeT destLen2; |
| 601 | int wasFinished; | 601 | int wasFinished; |
| 602 | 602 | ||
| 603 | PRF_STR("------- MixCoder Single ----------") | 603 | PRF_STR("------- MixCoder Single ----------") |
| 604 | 604 | ||
| 605 | srcLen2 = srcLenOrig; | ||
| 606 | destLen2 = destLenOrig; | 605 | destLen2 = destLenOrig; |
| 607 | 606 | if (p->numCoders != 1) | |
| 608 | { | 607 | { |
| 609 | IStateCoder *coder = &p->coders[0]; | 608 | if (destLen2 < p->outWritten) |
| 610 | res = coder->Code2(coder->p, NULL, &destLen2, src, &srcLen2, srcWasFinished, finishMode, | 609 | return SZ_ERROR_FAIL; |
| 611 | // &wasFinished, | 610 | destLen2 -= p->outWritten; |
| 612 | &p->status); | ||
| 613 | wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); | ||
| 614 | } | 611 | } |
| 615 | 612 | *srcLen = srcLenOrig; | |
| 616 | p->res = res; | ||
| 617 | |||
| 618 | /* | ||
| 619 | if (wasFinished) | ||
| 620 | p->status = CODER_STATUS_FINISHED_WITH_MARK; | ||
| 621 | else | ||
| 622 | { | 613 | { |
| 623 | if (res == SZ_OK) | 614 | IStateCoder *coder = &p->coders[0]; |
| 624 | if (destLen2 != destLenOrig) | 615 | res = coder->Code2(coder->p, NULL, &destLen2, src, srcLen, srcWasFinished, finishMode, &p->status); |
| 625 | p->status = CODER_STATUS_NEEDS_MORE_INPUT; | ||
| 626 | } | 616 | } |
| 627 | */ | 617 | p->res = res; |
| 628 | |||
| 629 | |||
| 630 | *srcLen = srcLen2; | ||
| 631 | src += srcLen2; | ||
| 632 | p->outWritten += destLen2; | 618 | p->outWritten += destLen2; |
| 619 | wasFinished = (p->status == CODER_STATUS_FINISHED_WITH_MARK); | ||
| 633 | 620 | ||
| 634 | if (res != SZ_OK || srcWasFinished || wasFinished) | 621 | if (res != SZ_OK || srcWasFinished || wasFinished) |
| 635 | p->wasFinished = True; | 622 | p->wasFinished = True; |
| @@ -1016,8 +1003,8 @@ SRes XzUnpacker_Code(CXzUnpacker *p, Byte *dest, SizeT *destLen, | |||
| 1016 | const Byte *src, SizeT *srcLen, int srcFinished, | 1003 | const Byte *src, SizeT *srcLen, int srcFinished, |
| 1017 | ECoderFinishMode finishMode, ECoderStatus *status) | 1004 | ECoderFinishMode finishMode, ECoderStatus *status) |
| 1018 | { | 1005 | { |
| 1019 | SizeT destLenOrig = *destLen; | 1006 | const SizeT destLenOrig = *destLen; |
| 1020 | SizeT srcLenOrig = *srcLen; | 1007 | const SizeT srcLenOrig = *srcLen; |
| 1021 | *destLen = 0; | 1008 | *destLen = 0; |
| 1022 | *srcLen = 0; | 1009 | *srcLen = 0; |
| 1023 | *status = CODER_STATUS_NOT_SPECIFIED; | 1010 | *status = CODER_STATUS_NOT_SPECIFIED; |
diff --git a/CPP/7zip/Archive/7z/7zIn.cpp b/CPP/7zip/Archive/7z/7zIn.cpp index e2efc52..eb39478 100644 --- a/CPP/7zip/Archive/7z/7zIn.cpp +++ b/CPP/7zip/Archive/7z/7zIn.cpp | |||
| @@ -698,22 +698,24 @@ void CInArchive::ReadPackInfo(CFolders &f) | |||
| 698 | 698 | ||
| 699 | WaitId(NID::kSize); | 699 | WaitId(NID::kSize); |
| 700 | f.PackPositions.Alloc(numPackStreams + 1); | 700 | f.PackPositions.Alloc(numPackStreams + 1); |
| 701 | UInt64 * const packPositions = f.PackPositions; | ||
| 701 | f.NumPackStreams = numPackStreams; | 702 | f.NumPackStreams = numPackStreams; |
| 702 | UInt64 sum = 0; | 703 | UInt64 sum = 0; |
| 703 | for (CNum i = 0; i < numPackStreams; i++) | 704 | for (CNum i = 0;;) |
| 704 | { | 705 | { |
| 705 | f.PackPositions[i] = sum; | 706 | packPositions[i] = sum; |
| 707 | if (i == numPackStreams) | ||
| 708 | break; | ||
| 709 | i++; | ||
| 706 | const UInt64 packSize = ReadNumber(); | 710 | const UInt64 packSize = ReadNumber(); |
| 707 | sum += packSize; | 711 | sum += packSize; |
| 708 | if (sum < packSize) | 712 | if (sum < packSize) |
| 709 | ThrowIncorrect(); | 713 | ThrowIncorrect(); |
| 710 | } | 714 | } |
| 711 | f.PackPositions[numPackStreams] = sum; | ||
| 712 | 715 | ||
| 713 | UInt64 type; | ||
| 714 | for (;;) | 716 | for (;;) |
| 715 | { | 717 | { |
| 716 | type = ReadID(); | 718 | const UInt64 type = ReadID(); |
| 717 | if (type == NID::kEnd) | 719 | if (type == NID::kEnd) |
| 718 | return; | 720 | return; |
| 719 | if (type == NID::kCRC) | 721 | if (type == NID::kCRC) |
| @@ -857,19 +859,20 @@ void CInArchive::ReadUnpackInfo( | |||
| 857 | StreamUsed[index] = true; | 859 | StreamUsed[index] = true; |
| 858 | } | 860 | } |
| 859 | 861 | ||
| 860 | for (i = 0; i < numCoders; i++) | 862 | for (i = 0;;) |
| 863 | { | ||
| 861 | if (!CoderUsed[i]) | 864 | if (!CoderUsed[i]) |
| 862 | { | ||
| 863 | indexOfMainStream = i; | ||
| 864 | break; | 865 | break; |
| 865 | } | 866 | if (++i == numCoders) |
| 866 | 867 | ThrowUnsupported(); | |
| 867 | if (i == numCoders) | 868 | } |
| 868 | ThrowUnsupported(); | 869 | indexOfMainStream = i; |
| 869 | } | 870 | } |
| 870 | 871 | ||
| 871 | folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; | 872 | folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; |
| 872 | numCodersOutStreams += numCoders; | 873 | numCodersOutStreams += numCoders; |
| 874 | if (numCodersOutStreams < numCoders) | ||
| 875 | ThrowUnsupported(); | ||
| 873 | folders.FoStartPackStreamIndex[fo] = packStreamIndex; | 876 | folders.FoStartPackStreamIndex[fo] = packStreamIndex; |
| 874 | if (numPackStreams > folders.NumPackStreams - packStreamIndex) | 877 | if (numPackStreams > folders.NumPackStreams - packStreamIndex) |
| 875 | ThrowIncorrect(); | 878 | ThrowIncorrect(); |
| @@ -880,7 +883,7 @@ void CInArchive::ReadUnpackInfo( | |||
| 880 | const size_t dataSize = (size_t)(_inByteBack->GetPtr() - startBufPtr); | 883 | const size_t dataSize = (size_t)(_inByteBack->GetPtr() - startBufPtr); |
| 881 | folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; | 884 | folders.FoToCoderUnpackSizes[fo] = numCodersOutStreams; |
| 882 | folders.FoStartPackStreamIndex[fo] = packStreamIndex; | 885 | folders.FoStartPackStreamIndex[fo] = packStreamIndex; |
| 883 | folders.FoCodersDataOffset[fo] = (size_t)(_inByteBack->GetPtr() - startBufPtr); | 886 | folders.FoCodersDataOffset[fo] = dataSize; |
| 884 | folders.CodersData.CopyFrom(startBufPtr, dataSize); | 887 | folders.CodersData.CopyFrom(startBufPtr, dataSize); |
| 885 | 888 | ||
| 886 | // if (folders.NumPackStreams != packStreamIndex) ThrowUnsupported(); | 889 | // if (folders.NumPackStreams != packStreamIndex) ThrowUnsupported(); |
| @@ -898,6 +901,8 @@ void CInArchive::ReadUnpackInfo( | |||
| 898 | return; | 901 | return; |
| 899 | if (type == NID::kCRC) | 902 | if (type == NID::kCRC) |
| 900 | { | 903 | { |
| 904 | if (!folders.FolderCRCs.Defs.IsEmpty()) | ||
| 905 | ThrowIncorrect(); | ||
| 901 | ReadHashDigests(numFolders, folders.FolderCRCs); | 906 | ReadHashDigests(numFolders, folders.FolderCRCs); |
| 902 | continue; | 907 | continue; |
| 903 | } | 908 | } |
| @@ -911,19 +916,35 @@ void CInArchive::ReadSubStreamsInfo( | |||
| 911 | CUInt32DefVector &digests) | 916 | CUInt32DefVector &digests) |
| 912 | { | 917 | { |
| 913 | folders.NumUnpackStreamsVector.Alloc(folders.NumFolders); | 918 | folders.NumUnpackStreamsVector.Alloc(folders.NumFolders); |
| 914 | CNum i; | ||
| 915 | for (i = 0; i < folders.NumFolders; i++) | ||
| 916 | folders.NumUnpackStreamsVector[i] = 1; | ||
| 917 | 919 | ||
| 920 | bool NumUnpackStream_isFilled = false; | ||
| 918 | UInt64 type; | 921 | UInt64 type; |
| 922 | |||
| 923 | CNum numUnpackStreams = folders.NumFolders; | ||
| 919 | 924 | ||
| 920 | for (;;) | 925 | for (;;) |
| 921 | { | 926 | { |
| 922 | type = ReadID(); | 927 | type = ReadID(); |
| 923 | if (type == NID::kNumUnpackStream) | 928 | if (type == NID::kNumUnpackStream) |
| 924 | { | 929 | { |
| 925 | for (i = 0; i < folders.NumFolders; i++) | 930 | if (NumUnpackStream_isFilled) |
| 926 | folders.NumUnpackStreamsVector[i] = ReadNum(); | 931 | ThrowIncorrect(); |
| 932 | NumUnpackStream_isFilled = true; | ||
| 933 | CNum numFolders = folders.NumFolders; | ||
| 934 | numUnpackStreams = 0; | ||
| 935 | if (numFolders) | ||
| 936 | { | ||
| 937 | UInt32 *dest = folders.NumUnpackStreamsVector.NonConstData(); | ||
| 938 | do | ||
| 939 | { | ||
| 940 | const CNum num = ReadNum(); | ||
| 941 | *dest++ = num; | ||
| 942 | numUnpackStreams += num; | ||
| 943 | if (numUnpackStreams < num) | ||
| 944 | ThrowUnsupported(); | ||
| 945 | } | ||
| 946 | while (--numFolders); | ||
| 947 | } | ||
| 927 | continue; | 948 | continue; |
| 928 | } | 949 | } |
| 929 | if (type == NID::kCRC || type == NID::kSize || type == NID::kEnd) | 950 | if (type == NID::kCRC || type == NID::kSize || type == NID::kEnd) |
| @@ -931,6 +952,20 @@ void CInArchive::ReadSubStreamsInfo( | |||
| 931 | SkipData(); | 952 | SkipData(); |
| 932 | } | 953 | } |
| 933 | 954 | ||
| 955 | if (!NumUnpackStream_isFilled) | ||
| 956 | { | ||
| 957 | CNum numFolders = folders.NumFolders; | ||
| 958 | if (numFolders) | ||
| 959 | { | ||
| 960 | UInt32 *dest = folders.NumUnpackStreamsVector.NonConstData(); | ||
| 961 | do | ||
| 962 | *dest++ = 1; | ||
| 963 | while (--numFolders); | ||
| 964 | } | ||
| 965 | } | ||
| 966 | |||
| 967 | unpackSizes.ClearAndReserve(numUnpackStreams); | ||
| 968 | CNum i; | ||
| 934 | if (type == NID::kSize) | 969 | if (type == NID::kSize) |
| 935 | { | 970 | { |
| 936 | for (i = 0; i < folders.NumFolders; i++) | 971 | for (i = 0; i < folders.NumFolders; i++) |
| @@ -943,16 +978,20 @@ void CInArchive::ReadSubStreamsInfo( | |||
| 943 | UInt64 sum = 0; | 978 | UInt64 sum = 0; |
| 944 | for (CNum j = 1; j < numSubstreams; j++) | 979 | for (CNum j = 1; j < numSubstreams; j++) |
| 945 | { | 980 | { |
| 981 | if (unpackSizes.Size() >= numUnpackStreams) | ||
| 982 | ThrowIncorrect(); // internal failure | ||
| 946 | const UInt64 size = ReadNumber(); | 983 | const UInt64 size = ReadNumber(); |
| 947 | unpackSizes.Add(size); | 984 | unpackSizes.AddInReserved(size); |
| 948 | sum += size; | 985 | sum += size; |
| 949 | if (sum < size) | 986 | if (sum < size) |
| 950 | ThrowIncorrect(); | 987 | ThrowIncorrect(); |
| 951 | } | 988 | } |
| 989 | if (unpackSizes.Size() >= numUnpackStreams) | ||
| 990 | ThrowIncorrect(); // internal failure | ||
| 952 | const UInt64 folderUnpackSize = folders.GetFolderUnpackSize(i); | 991 | const UInt64 folderUnpackSize = folders.GetFolderUnpackSize(i); |
| 953 | if (folderUnpackSize < sum) | 992 | if (folderUnpackSize < sum) |
| 954 | ThrowIncorrect(); | 993 | ThrowIncorrect(); |
| 955 | unpackSizes.Add(folderUnpackSize - sum); | 994 | unpackSizes.AddInReserved(folderUnpackSize - sum); |
| 956 | } | 995 | } |
| 957 | type = ReadID(); | 996 | type = ReadID(); |
| 958 | } | 997 | } |
| @@ -966,10 +1005,17 @@ void CInArchive::ReadSubStreamsInfo( | |||
| 966 | if (val > 1) | 1005 | if (val > 1) |
| 967 | ThrowIncorrect(); | 1006 | ThrowIncorrect(); |
| 968 | if (val == 1) | 1007 | if (val == 1) |
| 969 | unpackSizes.Add(folders.GetFolderUnpackSize(i)); | 1008 | { |
| 1009 | if (unpackSizes.Size() >= numUnpackStreams) | ||
| 1010 | ThrowIncorrect(); // internal failure | ||
| 1011 | unpackSizes.AddInReserved(folders.GetFolderUnpackSize(i)); | ||
| 1012 | } | ||
| 970 | } | 1013 | } |
| 971 | } | 1014 | } |
| 972 | 1015 | ||
| 1016 | if (unpackSizes.Size() != numUnpackStreams) | ||
| 1017 | ThrowIncorrect(); | ||
| 1018 | |||
| 973 | unsigned numDigests = 0; | 1019 | unsigned numDigests = 0; |
| 974 | for (i = 0; i < folders.NumFolders; i++) | 1020 | for (i = 0; i < folders.NumFolders; i++) |
| 975 | { | 1021 | { |
| @@ -984,6 +1030,8 @@ void CInArchive::ReadSubStreamsInfo( | |||
| 984 | break; | 1030 | break; |
| 985 | if (type == NID::kCRC) | 1031 | if (type == NID::kCRC) |
| 986 | { | 1032 | { |
| 1033 | if (!digests.Defs.IsEmpty()) | ||
| 1034 | ThrowIncorrect(); | ||
| 987 | // CUInt32DefVector digests2; | 1035 | // CUInt32DefVector digests2; |
| 988 | // ReadHashDigests(numDigests, digests2); | 1036 | // ReadHashDigests(numDigests, digests2); |
| 989 | CBoolVector digests2; | 1037 | CBoolVector digests2; |
| @@ -1092,10 +1140,13 @@ void CInArchive::ReadStreamsInfo( | |||
| 1092 | So we don't need to fill digests with values. */ | 1140 | So we don't need to fill digests with values. */ |
| 1093 | // digests.Vals.ClearAndSetSize(folders.NumFolders); | 1141 | // digests.Vals.ClearAndSetSize(folders.NumFolders); |
| 1094 | // BoolVector_Fill_False(digests.Defs, folders.NumFolders); | 1142 | // BoolVector_Fill_False(digests.Defs, folders.NumFolders); |
| 1143 | unpackSizes.ClearAndSetSize(folders.NumFolders); | ||
| 1144 | UInt64 * const unpackSizes2 = unpackSizes.NonConstData(); | ||
| 1145 | CNum * const numUnpackStreamsVector2 = folders.NumUnpackStreamsVector; | ||
| 1095 | for (CNum i = 0; i < folders.NumFolders; i++) | 1146 | for (CNum i = 0; i < folders.NumFolders; i++) |
| 1096 | { | 1147 | { |
| 1097 | folders.NumUnpackStreamsVector[i] = 1; | 1148 | numUnpackStreamsVector2[i] = 1; |
| 1098 | unpackSizes.Add(folders.GetFolderUnpackSize(i)); | 1149 | unpackSizes2[i] = folders.GetFolderUnpackSize(i); |
| 1099 | // digests.Vals[i] = 0; | 1150 | // digests.Vals[i] = 0; |
| 1100 | } | 1151 | } |
| 1101 | } | 1152 | } |
| @@ -1648,8 +1699,8 @@ HRESULT CInArchive::ReadDatabase2( | |||
| 1648 | db.PhySize = kHeaderSize; | 1699 | db.PhySize = kHeaderSize; |
| 1649 | 1700 | ||
| 1650 | db.IsArc = false; | 1701 | db.IsArc = false; |
| 1651 | if ((Int64)nextHeaderOffset < 0 || | 1702 | if (nextHeaderOffset >= (UInt64)1 << 62 || |
| 1652 | nextHeaderSize > ((UInt64)1 << 62)) | 1703 | nextHeaderSize > ((UInt64)1 << 48)) |
| 1653 | return S_FALSE; | 1704 | return S_FALSE; |
| 1654 | 1705 | ||
| 1655 | HeadersSize = kHeaderSize; | 1706 | HeadersSize = kHeaderSize; |
diff --git a/CPP/7zip/Archive/7z/7zUpdate.cpp b/CPP/7zip/Archive/7z/7zUpdate.cpp index 6ba04a2..b05d3cf 100644 --- a/CPP/7zip/Archive/7z/7zUpdate.cpp +++ b/CPP/7zip/Archive/7z/7zUpdate.cpp | |||
| @@ -36,13 +36,6 @@ struct CFilterMode | |||
| 36 | UInt32 Offset; // for k_ARM64 / k_RISCV | 36 | UInt32 Offset; // for k_ARM64 / k_RISCV |
| 37 | // UInt32 AlignSizeOpt; // for k_ARM64 | 37 | // UInt32 AlignSizeOpt; // for k_ARM64 |
| 38 | 38 | ||
| 39 | CFilterMode(): | ||
| 40 | Id(0), | ||
| 41 | Delta(0), | ||
| 42 | Offset(0) | ||
| 43 | // , AlignSizeOpt(0) | ||
| 44 | {} | ||
| 45 | |||
| 46 | void ClearFilterMode() | 39 | void ClearFilterMode() |
| 47 | { | 40 | { |
| 48 | Id = 0; | 41 | Id = 0; |
| @@ -437,7 +430,11 @@ struct CFilterMode2: public CFilterMode | |||
| 437 | bool Encrypted; | 430 | bool Encrypted; |
| 438 | unsigned GroupIndex; | 431 | unsigned GroupIndex; |
| 439 | 432 | ||
| 440 | CFilterMode2(): Encrypted(false) {} | 433 | void Construct() |
| 434 | { | ||
| 435 | ClearFilterMode(); | ||
| 436 | Encrypted = false; | ||
| 437 | } | ||
| 441 | 438 | ||
| 442 | int Compare(const CFilterMode2 &m) const | 439 | int Compare(const CFilterMode2 &m) const |
| 443 | { | 440 | { |
| @@ -546,6 +543,7 @@ static unsigned Get_FilterGroup_for_Folder( | |||
| 546 | CRecordVector<CFilterMode2> &filters, const CFolderEx &f, bool extractFilter) | 543 | CRecordVector<CFilterMode2> &filters, const CFolderEx &f, bool extractFilter) |
| 547 | { | 544 | { |
| 548 | CFilterMode2 m; | 545 | CFilterMode2 m; |
| 546 | m.Construct(); | ||
| 549 | // m.Id = 0; | 547 | // m.Id = 0; |
| 550 | // m.Delta = 0; | 548 | // m.Delta = 0; |
| 551 | // m.Offset = 0; | 549 | // m.Offset = 0; |
| @@ -795,14 +793,14 @@ struct CRefItem | |||
| 795 | unsigned NamePos; | 793 | unsigned NamePos; |
| 796 | unsigned ExtensionIndex; | 794 | unsigned ExtensionIndex; |
| 797 | 795 | ||
| 798 | CRefItem() {} | 796 | void Construct(UInt32 index, const CUpdateItem &ui, bool sortByType) |
| 799 | CRefItem(UInt32 index, const CUpdateItem &ui, bool sortByType): | ||
| 800 | UpdateItem(&ui), | ||
| 801 | Index(index), | ||
| 802 | ExtensionPos(0), | ||
| 803 | NamePos(0), | ||
| 804 | ExtensionIndex(0) | ||
| 805 | { | 797 | { |
| 798 | UpdateItem = &ui; | ||
| 799 | Index = index; | ||
| 800 | ExtensionPos = 0; | ||
| 801 | NamePos = 0; | ||
| 802 | ExtensionIndex = 0; | ||
| 803 | |||
| 806 | if (sortByType) | 804 | if (sortByType) |
| 807 | { | 805 | { |
| 808 | const int slashPos = ui.Name.ReverseFind_PathSepar(); | 806 | const int slashPos = ui.Name.ReverseFind_PathSepar(); |
| @@ -2154,6 +2152,7 @@ HRESULT Update( | |||
| 2154 | continue; | 2152 | continue; |
| 2155 | 2153 | ||
| 2156 | CFilterMode2 fm; | 2154 | CFilterMode2 fm; |
| 2155 | fm.Construct(); | ||
| 2157 | if (useFilters) | 2156 | if (useFilters) |
| 2158 | { | 2157 | { |
| 2159 | // analysis.ATime_Defined = false; | 2158 | // analysis.ATime_Defined = false; |
| @@ -2710,7 +2709,7 @@ HRESULT Update( | |||
| 2710 | unsigned i; | 2709 | unsigned i; |
| 2711 | 2710 | ||
| 2712 | for (i = 0; i < numFiles; i++) | 2711 | for (i = 0; i < numFiles; i++) |
| 2713 | refItems[i] = CRefItem(group.Indices[i], updateItems[group.Indices[i]], sortByType); | 2712 | refItems[i].Construct(group.Indices[i], updateItems[group.Indices[i]], sortByType); |
| 2714 | 2713 | ||
| 2715 | CSortParam sortParam; | 2714 | CSortParam sortParam; |
| 2716 | // sortParam.TreeFolders = &treeFolders; | 2715 | // sortParam.TreeFolders = &treeFolders; |
diff --git a/CPP/7zip/Archive/ApfsHandler.cpp b/CPP/7zip/Archive/ApfsHandler.cpp index 62b00ed..2876991 100644 --- a/CPP/7zip/Archive/ApfsHandler.cpp +++ b/CPP/7zip/Archive/ApfsHandler.cpp | |||
| @@ -3487,7 +3487,7 @@ static const CStatProp kProps[] = | |||
| 3487 | { NULL, kpidChangeTime, VT_FILETIME }, | 3487 | { NULL, kpidChangeTime, VT_FILETIME }, |
| 3488 | { "Added Time", kpidAddTime, VT_FILETIME }, | 3488 | { "Added Time", kpidAddTime, VT_FILETIME }, |
| 3489 | { NULL, kpidMethod, VT_BSTR }, | 3489 | { NULL, kpidMethod, VT_BSTR }, |
| 3490 | { NULL, kpidINode, VT_UI8 }, | 3490 | { NULL, kpidINode, VT_UI4 }, |
| 3491 | { NULL, kpidLinks, VT_UI4 }, | 3491 | { NULL, kpidLinks, VT_UI4 }, |
| 3492 | { NULL, kpidSymLink, VT_BSTR }, | 3492 | { NULL, kpidSymLink, VT_BSTR }, |
| 3493 | { NULL, kpidUserId, VT_UI4 }, | 3493 | { NULL, kpidUserId, VT_UI4 }, |
| @@ -3496,7 +3496,7 @@ static const CStatProp kProps[] = | |||
| 3496 | #ifdef APFS_SHOW_ALT_STREAMS | 3496 | #ifdef APFS_SHOW_ALT_STREAMS |
| 3497 | { NULL, kpidIsAltStream, VT_BOOL }, | 3497 | { NULL, kpidIsAltStream, VT_BOOL }, |
| 3498 | #endif | 3498 | #endif |
| 3499 | { "Parent iNode", kpidParentINode, VT_UI8 }, | 3499 | { "Parent iNode", kpidParentINode, VT_UI4 }, |
| 3500 | { "Primary Name", kpidPrimeName, VT_BSTR }, | 3500 | { "Primary Name", kpidPrimeName, VT_BSTR }, |
| 3501 | { "Generation", kpidGeneration, VT_UI4 }, | 3501 | { "Generation", kpidGeneration, VT_UI4 }, |
| 3502 | { "Written Size", kpidBytesWritten, VT_UI8 }, | 3502 | { "Written Size", kpidBytesWritten, VT_UI8 }, |
diff --git a/CPP/7zip/Archive/ExtHandler.cpp b/CPP/7zip/Archive/ExtHandler.cpp index 5af2a92..d379373 100644 --- a/CPP/7zip/Archive/ExtHandler.cpp +++ b/CPP/7zip/Archive/ExtHandler.cpp | |||
| @@ -628,6 +628,8 @@ struct CNode | |||
| 628 | UInt32 Gid; // fixed 21.02 | 628 | UInt32 Gid; // fixed 21.02 |
| 629 | // UInt16 Checksum; | 629 | // UInt16 Checksum; |
| 630 | 630 | ||
| 631 | UInt32 NumLinksCalced; | ||
| 632 | |||
| 631 | UInt64 FileSize; | 633 | UInt64 FileSize; |
| 632 | CExtTime MTime; | 634 | CExtTime MTime; |
| 633 | CExtTime ATime; | 635 | CExtTime ATime; |
| @@ -639,17 +641,16 @@ struct CNode | |||
| 639 | UInt32 NumLinks; | 641 | UInt32 NumLinks; |
| 640 | UInt32 Flags; | 642 | UInt32 Flags; |
| 641 | 643 | ||
| 642 | UInt32 NumLinksCalced; | ||
| 643 | |||
| 644 | Byte Block[kNodeBlockFieldSize]; | 644 | Byte Block[kNodeBlockFieldSize]; |
| 645 | 645 | ||
| 646 | CNode(): | 646 | void Construct() |
| 647 | ParentNode(-1), | 647 | { |
| 648 | ItemIndex(-1), | 648 | ParentNode = -1; |
| 649 | SymLinkIndex(-1), | 649 | ItemIndex = -1; |
| 650 | DirIndex(-1), | 650 | SymLinkIndex = -1; |
| 651 | NumLinksCalced(0) | 651 | DirIndex = -1; |
| 652 | {} | 652 | NumLinksCalced = 0; |
| 653 | } | ||
| 653 | 654 | ||
| 654 | bool IsFlags_HUGE() const { return (Flags & k_NodeFlags_HUGE) != 0; } | 655 | bool IsFlags_HUGE() const { return (Flags & k_NodeFlags_HUGE) != 0; } |
| 655 | bool IsFlags_EXTENTS() const { return (Flags & k_NodeFlags_EXTENTS) != 0; } | 656 | bool IsFlags_EXTENTS() const { return (Flags & k_NodeFlags_EXTENTS) != 0; } |
| @@ -1172,21 +1173,19 @@ HRESULT CHandler::Open2(IInStream *inStream) | |||
| 1172 | { | 1173 | { |
| 1173 | // ---------- Read groups ---------- | 1174 | // ---------- Read groups ---------- |
| 1174 | 1175 | ||
| 1175 | CByteBuffer gdBuf; | ||
| 1176 | const size_t gdBufSize = (size_t)numGroups << gdBits; | 1176 | const size_t gdBufSize = (size_t)numGroups << gdBits; |
| 1177 | if ((gdBufSize >> gdBits) != numGroups) | 1177 | if ((gdBufSize >> gdBits) != numGroups) |
| 1178 | return S_FALSE; | 1178 | return S_FALSE; |
| 1179 | CByteBuffer gdBuf; | ||
| 1179 | gdBuf.Alloc(gdBufSize); | 1180 | gdBuf.Alloc(gdBufSize); |
| 1180 | RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize)) | 1181 | RINOK(SeekAndRead(inStream, (_h.BlockBits <= 10 ? 2 : 1), gdBuf, gdBufSize)) |
| 1181 | 1182 | ||
| 1182 | for (unsigned i = 0; i < numGroups; i++) | 1183 | const unsigned gd_Size = (unsigned)1 << gdBits; |
| 1184 | const Byte *p = gdBuf; | ||
| 1185 | for (unsigned i = 0; i < numGroups; i++, p += gd_Size) | ||
| 1183 | { | 1186 | { |
| 1184 | CGroupDescriptor gd; | 1187 | CGroupDescriptor gd; |
| 1185 | |||
| 1186 | const Byte *p = gdBuf + ((size_t)i << gdBits); | ||
| 1187 | const unsigned gd_Size = (unsigned)1 << gdBits; | ||
| 1188 | gd.Parse(p, gd_Size); | 1188 | gd.Parse(p, gd_Size); |
| 1189 | |||
| 1190 | if (_h.UseMetadataChecksum()) | 1189 | if (_h.UseMetadataChecksum()) |
| 1191 | { | 1190 | { |
| 1192 | // use CRC32c | 1191 | // use CRC32c |
| @@ -1228,7 +1227,10 @@ HRESULT CHandler::Open2(IInStream *inStream) | |||
| 1228 | if (numNodes > (1 << 24)) | 1227 | if (numNodes > (1 << 24)) |
| 1229 | return S_FALSE; | 1228 | return S_FALSE; |
| 1230 | } | 1229 | } |
| 1231 | 1230 | ||
| 1231 | const size_t blockSize = (size_t)1 << _h.BlockBits; | ||
| 1232 | if (numNodes > blockSize * 8) | ||
| 1233 | return S_FALSE; | ||
| 1232 | const UInt32 numReserveInodes = _h.NumInodes - _h.NumFreeInodes + 1; | 1234 | const UInt32 numReserveInodes = _h.NumInodes - _h.NumFreeInodes + 1; |
| 1233 | // numReserveInodes = _h.NumInodes + 1; | 1235 | // numReserveInodes = _h.NumInodes + 1; |
| 1234 | if (numReserveInodes != 0) | 1236 | if (numReserveInodes != 0) |
| @@ -1241,7 +1243,6 @@ HRESULT CHandler::Open2(IInStream *inStream) | |||
| 1241 | nodesData.Alloc(nodesDataSize); | 1243 | nodesData.Alloc(nodesDataSize); |
| 1242 | 1244 | ||
| 1243 | CByteBuffer nodesMap; | 1245 | CByteBuffer nodesMap; |
| 1244 | const size_t blockSize = (size_t)1 << _h.BlockBits; | ||
| 1245 | nodesMap.Alloc(blockSize); | 1246 | nodesMap.Alloc(blockSize); |
| 1246 | 1247 | ||
| 1247 | unsigned globalNodeIndex = 0; | 1248 | unsigned globalNodeIndex = 0; |
| @@ -1282,6 +1283,7 @@ HRESULT CHandler::Open2(IInStream *inStream) | |||
| 1282 | } | 1283 | } |
| 1283 | 1284 | ||
| 1284 | CNode node; | 1285 | CNode node; |
| 1286 | node.Construct(); | ||
| 1285 | 1287 | ||
| 1286 | PRF(printf("\nnode = %5d ", (unsigned)n)); | 1288 | PRF(printf("\nnode = %5d ", (unsigned)n)); |
| 1287 | 1289 | ||
diff --git a/CPP/7zip/Archive/HfsHandler.cpp b/CPP/7zip/Archive/HfsHandler.cpp index 46e0239..5df00ed 100644 --- a/CPP/7zip/Archive/HfsHandler.cpp +++ b/CPP/7zip/Archive/HfsHandler.cpp | |||
| @@ -437,7 +437,7 @@ struct CRef | |||
| 437 | int AttrIndex; | 437 | int AttrIndex; |
| 438 | int Parent; | 438 | int Parent; |
| 439 | 439 | ||
| 440 | CRef(): AttrIndex(kAttrIndex_Item), Parent(-1) {} | 440 | void Construct() { AttrIndex = kAttrIndex_Item; Parent = -1; } |
| 441 | bool IsResource() const { return AttrIndex == kAttrIndex_Resource; } | 441 | bool IsResource() const { return AttrIndex == kAttrIndex_Resource; } |
| 442 | bool IsAltStream() const { return AttrIndex != kAttrIndex_Item; } | 442 | bool IsAltStream() const { return AttrIndex != kAttrIndex_Item; } |
| 443 | bool IsItem() const { return AttrIndex == kAttrIndex_Item; } | 443 | bool IsItem() const { return AttrIndex == kAttrIndex_Item; } |
| @@ -1259,6 +1259,7 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents | |||
| 1259 | IdToIndexMap.Add(pair); | 1259 | IdToIndexMap.Add(pair); |
| 1260 | 1260 | ||
| 1261 | CRef ref; | 1261 | CRef ref; |
| 1262 | ref.Construct(); | ||
| 1262 | ref.ItemIndex = i; | 1263 | ref.ItemIndex = i; |
| 1263 | Refs.Add(ref); | 1264 | Refs.Add(ref); |
| 1264 | 1265 | ||
| @@ -1317,6 +1318,7 @@ HRESULT CDatabase::LoadCatalog(const CFork &fork, const CObjectVector<CIdExtents | |||
| 1317 | ThereAreAltStreams = true; | 1318 | ThereAreAltStreams = true; |
| 1318 | 1319 | ||
| 1319 | CRef ref; | 1320 | CRef ref; |
| 1321 | ref.Construct(); | ||
| 1320 | ref.AttrIndex = (int)i; | 1322 | ref.AttrIndex = (int)i; |
| 1321 | ref.Parent = refIndex; | 1323 | ref.Parent = refIndex; |
| 1322 | ref.ItemIndex = Refs[refIndex].ItemIndex; | 1324 | ref.ItemIndex = Refs[refIndex].ItemIndex; |
diff --git a/CPP/7zip/Archive/LpHandler.cpp b/CPP/7zip/Archive/LpHandler.cpp index 926b654..1f44c09 100644 --- a/CPP/7zip/Archive/LpHandler.cpp +++ b/CPP/7zip/Archive/LpHandler.cpp | |||
| @@ -223,12 +223,13 @@ struct CPartition | |||
| 223 | UInt64 GetSize() const { return NumSectors << kSectorSizeLog; } | 223 | UInt64 GetSize() const { return NumSectors << kSectorSizeLog; } |
| 224 | UInt64 GetPackSize() const { return NumSectors_Pack << kSectorSizeLog; } | 224 | UInt64 GetPackSize() const { return NumSectors_Pack << kSectorSizeLog; } |
| 225 | 225 | ||
| 226 | CPartition(): | 226 | void Construct() |
| 227 | MethodsMask(0), | 227 | { |
| 228 | NumSectors(0), | 228 | MethodsMask = 0; |
| 229 | NumSectors_Pack(0), | 229 | NumSectors = 0; |
| 230 | Ext(NULL) | 230 | NumSectors_Pack = 0; |
| 231 | {} | 231 | Ext = NULL; |
| 232 | } | ||
| 232 | }; | 233 | }; |
| 233 | 234 | ||
| 234 | 235 | ||
| @@ -609,6 +610,7 @@ HRESULT CHandler::Open2(IInStream *stream) | |||
| 609 | for (UInt32 i = 0; i < d.num_entries; i++) | 610 | for (UInt32 i = 0; i < d.num_entries; i++) |
| 610 | { | 611 | { |
| 611 | CPartition part; | 612 | CPartition part; |
| 613 | part.Construct(); | ||
| 612 | part.Parse(buffer + d.offset + i * d.entry_size); | 614 | part.Parse(buffer + d.offset + i * d.entry_size); |
| 613 | const UInt32 extLimit = part.first_extent_index + part.num_extents; | 615 | const UInt32 extLimit = part.first_extent_index + part.num_extents; |
| 614 | if (extLimit < part.first_extent_index || | 616 | if (extLimit < part.first_extent_index || |
diff --git a/CPP/7zip/Archive/LvmHandler.cpp b/CPP/7zip/Archive/LvmHandler.cpp index 8d1655e..9e6fed2 100644 --- a/CPP/7zip/Archive/LvmHandler.cpp +++ b/CPP/7zip/Archive/LvmHandler.cpp | |||
| @@ -1050,8 +1050,6 @@ Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val | |||
| 1050 | COM_TRY_BEGIN | 1050 | COM_TRY_BEGIN |
| 1051 | NCOM::CPropVariant prop; | 1051 | NCOM::CPropVariant prop; |
| 1052 | 1052 | ||
| 1053 | const CItem &item = _items[index]; | ||
| 1054 | |||
| 1055 | // const CLogVol &item = _items[index]; | 1053 | // const CLogVol &item = _items[index]; |
| 1056 | 1054 | ||
| 1057 | if (index >= _items.Size()) | 1055 | if (index >= _items.Size()) |
| @@ -1070,6 +1068,7 @@ Z7_COM7F_IMF(CHandler::GetProperty(UInt32 index, PROPID propID, PROPVARIANT *val | |||
| 1070 | } | 1068 | } |
| 1071 | else | 1069 | else |
| 1072 | { | 1070 | { |
| 1071 | const CItem &item = _items[index]; | ||
| 1073 | switch (propID) | 1072 | switch (propID) |
| 1074 | { | 1073 | { |
| 1075 | case kpidPath: | 1074 | case kpidPath: |
diff --git a/CPP/7zip/Archive/MbrHandler.cpp b/CPP/7zip/Archive/MbrHandler.cpp index 82d34fd..53663e8 100644 --- a/CPP/7zip/Archive/MbrHandler.cpp +++ b/CPP/7zip/Archive/MbrHandler.cpp | |||
| @@ -53,7 +53,12 @@ struct CChs | |||
| 53 | SectCyl = p[1]; | 53 | SectCyl = p[1]; |
| 54 | Cyl8 = p[2]; | 54 | Cyl8 = p[2]; |
| 55 | } | 55 | } |
| 56 | bool Check() const { return GetSector() > 0; } | 56 | bool Check() const |
| 57 | { | ||
| 58 | if ((Head | SectCyl | Cyl8) == 0) | ||
| 59 | return true; | ||
| 60 | return GetSector() > 0; | ||
| 61 | } | ||
| 57 | }; | 62 | }; |
| 58 | 63 | ||
| 59 | 64 | ||
diff --git a/CPP/7zip/Archive/Nsis/NsisIn.cpp b/CPP/7zip/Archive/Nsis/NsisIn.cpp index 194e5bf..577062e 100644 --- a/CPP/7zip/Archive/Nsis/NsisIn.cpp +++ b/CPP/7zip/Archive/Nsis/NsisIn.cpp | |||
| @@ -190,7 +190,7 @@ static const CCommandInfo k_Commands[kNumCmds] = | |||
| 190 | { 2 }, // "SetFileAttributes" }, | 190 | { 2 }, // "SetFileAttributes" }, |
| 191 | { 3 }, // CreateDirectory, SetOutPath | 191 | { 3 }, // CreateDirectory, SetOutPath |
| 192 | { 3 }, // "IfFileExists" }, | 192 | { 3 }, // "IfFileExists" }, |
| 193 | { 3 }, // SetRebootFlag, ... | 193 | { 4 }, // SetRebootFlag, ... |
| 194 | { 4 }, // "If" }, // IfAbort, IfSilent, IfErrors, IfRebootFlag | 194 | { 4 }, // "If" }, // IfAbort, IfSilent, IfErrors, IfRebootFlag |
| 195 | { 2 }, // "Get" }, // GetInstDirError, GetErrorLevel | 195 | { 2 }, // "Get" }, // GetInstDirError, GetErrorLevel |
| 196 | { 4 }, // "Rename" }, | 196 | { 4 }, // "Rename" }, |
| @@ -3910,6 +3910,10 @@ HRESULT CInArchive::ReadEntries(const CBlockHeader &bh) | |||
| 3910 | if (params[2] != 0) | 3910 | if (params[2] != 0) |
| 3911 | { | 3911 | { |
| 3912 | s += " lastused"; | 3912 | s += " lastused"; |
| 3913 | // (params[3] == (UInt32)(Int32)-1) is possible in NSIS 3.10. | ||
| 3914 | // SetDetailsPrint lastused (special) | ||
| 3915 | if ((Int32)params[3] < 0) | ||
| 3916 | s += " ; (special)"; | ||
| 3913 | break; | 3917 | break; |
| 3914 | } | 3918 | } |
| 3915 | UInt32 v; | 3919 | UInt32 v; |
diff --git a/CPP/7zip/Archive/NtfsHandler.cpp b/CPP/7zip/Archive/NtfsHandler.cpp index d26612b..006f0ad 100644 --- a/CPP/7zip/Archive/NtfsHandler.cpp +++ b/CPP/7zip/Archive/NtfsHandler.cpp | |||
| @@ -1433,7 +1433,12 @@ struct CItem | |||
| 1433 | int ParentHost; /* index in Items array, if it's AltStream | 1433 | int ParentHost; /* index in Items array, if it's AltStream |
| 1434 | -1: if it's not AltStream */ | 1434 | -1: if it's not AltStream */ |
| 1435 | 1435 | ||
| 1436 | CItem(): DataIndex(k_Item_DataIndex_IsDir), ParentFolder(-1), ParentHost(-1) {} | 1436 | void Construct() |
| 1437 | { | ||
| 1438 | DataIndex = k_Item_DataIndex_IsDir; | ||
| 1439 | ParentFolder = -1; | ||
| 1440 | ParentHost = -1; | ||
| 1441 | } | ||
| 1437 | 1442 | ||
| 1438 | bool IsAltStream() const { return ParentHost != -1; } | 1443 | bool IsAltStream() const { return ParentHost != -1; } |
| 1439 | bool IsDir() const { return DataIndex == k_Item_DataIndex_IsDir; } | 1444 | bool IsDir() const { return DataIndex == k_Item_DataIndex_IsDir; } |
| @@ -2060,6 +2065,7 @@ HRESULT CDatabase::Open() | |||
| 2060 | } | 2065 | } |
| 2061 | 2066 | ||
| 2062 | CItem item; | 2067 | CItem item; |
| 2068 | item.Construct(); | ||
| 2063 | item.NameIndex = t; | 2069 | item.NameIndex = t; |
| 2064 | item.RecIndex = i; | 2070 | item.RecIndex = i; |
| 2065 | item.DataIndex = rec.IsDir() ? | 2071 | item.DataIndex = rec.IsDir() ? |
diff --git a/CPP/7zip/Archive/PeHandler.cpp b/CPP/7zip/Archive/PeHandler.cpp index 79f89ef..f5f66b0 100644 --- a/CPP/7zip/Archive/PeHandler.cpp +++ b/CPP/7zip/Archive/PeHandler.cpp | |||
| @@ -758,7 +758,13 @@ struct CMixItem | |||
| 758 | int StringIndex; | 758 | int StringIndex; |
| 759 | int VersionIndex; | 759 | int VersionIndex; |
| 760 | 760 | ||
| 761 | CMixItem(): SectionIndex(-1), ResourceIndex(-1), StringIndex(-1), VersionIndex(-1) {} | 761 | void Construct() |
| 762 | { | ||
| 763 | SectionIndex = -1; | ||
| 764 | ResourceIndex = -1; | ||
| 765 | StringIndex = -1; | ||
| 766 | VersionIndex = -1; | ||
| 767 | } | ||
| 762 | bool IsSectionItem() const { return ResourceIndex < 0 && StringIndex < 0 && VersionIndex < 0; } | 768 | bool IsSectionItem() const { return ResourceIndex < 0 && StringIndex < 0 && VersionIndex < 0; } |
| 763 | }; | 769 | }; |
| 764 | 770 | ||
| @@ -820,20 +826,22 @@ Z7_CLASS_IMP_CHandler_IInArchive_2( | |||
| 820 | CObjectVector<CStringKeyValue> _versionKeys; | 826 | CObjectVector<CStringKeyValue> _versionKeys; |
| 821 | 827 | ||
| 822 | CByteBuffer _buf; | 828 | CByteBuffer _buf; |
| 829 | |||
| 823 | bool _oneLang; | 830 | bool _oneLang; |
| 824 | UString _resourcesPrefix; | ||
| 825 | CUsedBitmap _usedRes; | ||
| 826 | // bool _parseResources; | 831 | // bool _parseResources; |
| 827 | bool _checksumError; | 832 | bool _checksumError; |
| 828 | bool _sectionsError; | 833 | bool _sectionsError; |
| 829 | 834 | ||
| 835 | bool _coffMode; | ||
| 836 | bool _allowTail; | ||
| 837 | |||
| 838 | UString _resourcesPrefix; | ||
| 839 | CUsedBitmap _usedRes; | ||
| 840 | |||
| 830 | bool IsOpt() const { return _header.OptHeaderSize != 0; } | 841 | bool IsOpt() const { return _header.OptHeaderSize != 0; } |
| 831 | 842 | ||
| 832 | COptHeader _optHeader; | 843 | COptHeader _optHeader; |
| 833 | 844 | ||
| 834 | bool _coffMode; | ||
| 835 | bool _allowTail; | ||
| 836 | |||
| 837 | HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection); | 845 | HRESULT LoadDebugSections(IInStream *stream, bool &thereIsSection); |
| 838 | HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback); | 846 | HRESULT Open2(IInStream *stream, IArchiveOpenCallback *callback); |
| 839 | 847 | ||
| @@ -2269,6 +2277,7 @@ HRESULT CHandler::OpenResources(unsigned sectionIndex, IInStream *stream, IArchi | |||
| 2269 | if (ParseVersion((const Byte *)_buf + offset, item.Size, f, _versionKeys)) | 2277 | if (ParseVersion((const Byte *)_buf + offset, item.Size, f, _versionKeys)) |
| 2270 | { | 2278 | { |
| 2271 | CMixItem mixItem; | 2279 | CMixItem mixItem; |
| 2280 | mixItem.Construct(); | ||
| 2272 | mixItem.VersionIndex = (int)_versionFiles.Size(); | 2281 | mixItem.VersionIndex = (int)_versionFiles.Size(); |
| 2273 | mixItem.SectionIndex = (int)sectionIndex; // check it !!!! | 2282 | mixItem.SectionIndex = (int)sectionIndex; // check it !!!! |
| 2274 | CByteBuffer_WithLang &vf = _versionFiles.AddNew(); | 2283 | CByteBuffer_WithLang &vf = _versionFiles.AddNew(); |
| @@ -2300,6 +2309,7 @@ HRESULT CHandler::OpenResources(unsigned sectionIndex, IInStream *stream, IArchi | |||
| 2300 | if (_strings[i].FinalSize() == 0) | 2309 | if (_strings[i].FinalSize() == 0) |
| 2301 | continue; | 2310 | continue; |
| 2302 | CMixItem mixItem; | 2311 | CMixItem mixItem; |
| 2312 | mixItem.Construct(); | ||
| 2303 | mixItem.StringIndex = (int)i; | 2313 | mixItem.StringIndex = (int)i; |
| 2304 | mixItem.SectionIndex = (int)sectionIndex; | 2314 | mixItem.SectionIndex = (int)sectionIndex; |
| 2305 | _mixItems.Add(mixItem); | 2315 | _mixItems.Add(mixItem); |
| @@ -2654,6 +2664,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) | |||
| 2654 | if (item.Enabled) | 2664 | if (item.Enabled) |
| 2655 | { | 2665 | { |
| 2656 | CMixItem mixItem; | 2666 | CMixItem mixItem; |
| 2667 | mixItem.Construct(); | ||
| 2657 | mixItem.SectionIndex = (int)i; | 2668 | mixItem.SectionIndex = (int)i; |
| 2658 | mixItem.ResourceIndex = (int)j; | 2669 | mixItem.ResourceIndex = (int)j; |
| 2659 | if (item.IsRcDataOrUnknown()) | 2670 | if (item.IsRcDataOrUnknown()) |
| @@ -2717,6 +2728,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *callback) | |||
| 2717 | } | 2728 | } |
| 2718 | 2729 | ||
| 2719 | CMixItem mixItem; | 2730 | CMixItem mixItem; |
| 2731 | mixItem.Construct(); | ||
| 2720 | mixItem.SectionIndex = (int)i; | 2732 | mixItem.SectionIndex = (int)i; |
| 2721 | _mixItems.Add(mixItem); | 2733 | _mixItems.Add(mixItem); |
| 2722 | } | 2734 | } |
diff --git a/CPP/7zip/Archive/SparseHandler.cpp b/CPP/7zip/Archive/SparseHandler.cpp index 5e666ed..70bcb6f 100644 --- a/CPP/7zip/Archive/SparseHandler.cpp +++ b/CPP/7zip/Archive/SparseHandler.cpp | |||
| @@ -78,7 +78,7 @@ struct CChunk | |||
| 78 | Byte Fill [kFillSize]; | 78 | Byte Fill [kFillSize]; |
| 79 | UInt64 PhyOffset; | 79 | UInt64 PhyOffset; |
| 80 | 80 | ||
| 81 | CChunk() | 81 | void Construct() |
| 82 | { | 82 | { |
| 83 | Fill[0] = | 83 | Fill[0] = |
| 84 | Fill[1] = | 84 | Fill[1] = |
| @@ -293,6 +293,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *openCallback) | |||
| 293 | if (size < kChunkHeaderSize) | 293 | if (size < kChunkHeaderSize) |
| 294 | return S_FALSE; | 294 | return S_FALSE; |
| 295 | CChunk c; | 295 | CChunk c; |
| 296 | c.Construct(); | ||
| 296 | c.PhyOffset = offset + kChunkHeaderSize; | 297 | c.PhyOffset = offset + kChunkHeaderSize; |
| 297 | c.VirtBlock = virtBlock; | 298 | c.VirtBlock = virtBlock; |
| 298 | offset += size; | 299 | offset += size; |
| @@ -364,6 +365,7 @@ HRESULT CHandler::Open2(IInStream *stream, IArchiveOpenCallback *openCallback) | |||
| 364 | 365 | ||
| 365 | { | 366 | { |
| 366 | CChunk c; | 367 | CChunk c; |
| 368 | c.Construct(); | ||
| 367 | c.VirtBlock = virtBlock; | 369 | c.VirtBlock = virtBlock; |
| 368 | c.PhyOffset = offset; | 370 | c.PhyOffset = offset; |
| 369 | Chunks.AddInReserved(c); | 371 | Chunks.AddInReserved(c); |
diff --git a/CPP/7zip/Archive/SquashfsHandler.cpp b/CPP/7zip/Archive/SquashfsHandler.cpp index b66be04..83cb1cf 100644 --- a/CPP/7zip/Archive/SquashfsHandler.cpp +++ b/CPP/7zip/Archive/SquashfsHandler.cpp | |||
| @@ -812,7 +812,7 @@ struct CItem | |||
| 812 | int Parent; | 812 | int Parent; |
| 813 | UInt32 Ptr; | 813 | UInt32 Ptr; |
| 814 | 814 | ||
| 815 | CItem(): Node(-1), Parent(-1), Ptr(0) {} | 815 | void Construct() { Node = -1; Parent = -1; Ptr = 0; } |
| 816 | }; | 816 | }; |
| 817 | 817 | ||
| 818 | struct CData | 818 | struct CData |
| @@ -1497,7 +1497,7 @@ HRESULT CHandler::OpenDir(int parent, UInt32 startBlock, UInt32 offset, unsigned | |||
| 1497 | if (rem == 0) | 1497 | if (rem == 0) |
| 1498 | return S_FALSE; | 1498 | return S_FALSE; |
| 1499 | 1499 | ||
| 1500 | UInt32 nameOffset = _h.GetFileNameOffset(); | 1500 | const UInt32 nameOffset = _h.GetFileNameOffset(); |
| 1501 | if (rem < nameOffset) | 1501 | if (rem < nameOffset) |
| 1502 | return S_FALSE; | 1502 | return S_FALSE; |
| 1503 | 1503 | ||
| @@ -1505,7 +1505,7 @@ HRESULT CHandler::OpenDir(int parent, UInt32 startBlock, UInt32 offset, unsigned | |||
| 1505 | return S_FALSE; | 1505 | return S_FALSE; |
| 1506 | if (_openCallback) | 1506 | if (_openCallback) |
| 1507 | { | 1507 | { |
| 1508 | UInt64 numFiles = _items.Size(); | 1508 | const UInt64 numFiles = _items.Size(); |
| 1509 | if ((numFiles & 0xFFFF) == 0) | 1509 | if ((numFiles & 0xFFFF) == 0) |
| 1510 | { | 1510 | { |
| 1511 | RINOK(_openCallback->SetCompleted(&numFiles, NULL)) | 1511 | RINOK(_openCallback->SetCompleted(&numFiles, NULL)) |
| @@ -1513,6 +1513,7 @@ HRESULT CHandler::OpenDir(int parent, UInt32 startBlock, UInt32 offset, unsigned | |||
| 1513 | } | 1513 | } |
| 1514 | 1514 | ||
| 1515 | CItem item; | 1515 | CItem item; |
| 1516 | item.Construct(); | ||
| 1516 | item.Ptr = (UInt32)(p - (const Byte *)_dirs.Data); | 1517 | item.Ptr = (UInt32)(p - (const Byte *)_dirs.Data); |
| 1517 | 1518 | ||
| 1518 | UInt32 size; | 1519 | UInt32 size; |
diff --git a/CPP/7zip/Archive/Wim/WimHandlerOut.cpp b/CPP/7zip/Archive/Wim/WimHandlerOut.cpp index 3b2cb31..0fd7d23 100644 --- a/CPP/7zip/Archive/Wim/WimHandlerOut.cpp +++ b/CPP/7zip/Archive/Wim/WimHandlerOut.cpp | |||
| @@ -177,7 +177,12 @@ struct CUpdateItem | |||
| 177 | int InArcIndex; // >= 0, if we use OLD Data | 177 | int InArcIndex; // >= 0, if we use OLD Data |
| 178 | // -1, if we use NEW Data | 178 | // -1, if we use NEW Data |
| 179 | 179 | ||
| 180 | CUpdateItem(): MetaIndex(-1), AltStreamIndex(-1), InArcIndex(-1) {} | 180 | void Construct() |
| 181 | { | ||
| 182 | MetaIndex = -1; | ||
| 183 | AltStreamIndex = -1; | ||
| 184 | InArcIndex = -1; | ||
| 185 | } | ||
| 181 | }; | 186 | }; |
| 182 | 187 | ||
| 183 | 188 | ||
| @@ -894,6 +899,7 @@ Z7_COM7F_IMF(CHandler::UpdateItems(ISequentialOutStream *outSeqStream, UInt32 nu | |||
| 894 | for (i = 0; i < numItems; i++) | 899 | for (i = 0; i < numItems; i++) |
| 895 | { | 900 | { |
| 896 | CUpdateItem ui; | 901 | CUpdateItem ui; |
| 902 | ui.Construct(); | ||
| 897 | UInt32 indexInArchive; | 903 | UInt32 indexInArchive; |
| 898 | Int32 newData, newProps; | 904 | Int32 newData, newProps; |
| 899 | RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive)) | 905 | RINOK(callback->GetUpdateItemInfo(i, &newData, &newProps, &indexInArchive)) |
diff --git a/CPP/7zip/Archive/Wim/WimIn.cpp b/CPP/7zip/Archive/Wim/WimIn.cpp index b2236dd..33fbe82 100644 --- a/CPP/7zip/Archive/Wim/WimIn.cpp +++ b/CPP/7zip/Archive/Wim/WimIn.cpp | |||
| @@ -609,6 +609,7 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent, unsigned dirLevel) | |||
| 609 | return S_FALSE; | 609 | return S_FALSE; |
| 610 | 610 | ||
| 611 | CItem item; | 611 | CItem item; |
| 612 | item.Construct(); | ||
| 612 | const UInt32 attrib = Get32(p + 8); | 613 | const UInt32 attrib = Get32(p + 8); |
| 613 | item.IsDir = ((attrib & 0x10) != 0); | 614 | item.IsDir = ((attrib & 0x10) != 0); |
| 614 | { | 615 | { |
| @@ -729,6 +730,7 @@ HRESULT CDatabase::ParseDirItem(size_t pos, int parent, unsigned dirLevel) | |||
| 729 | { | 730 | { |
| 730 | ThereAreAltStreams = true; | 731 | ThereAreAltStreams = true; |
| 731 | CItem item2; | 732 | CItem item2; |
| 733 | item2.Construct(); | ||
| 732 | item2.Offset = pos; | 734 | item2.Offset = pos; |
| 733 | item2.IsAltStream = true; | 735 | item2.IsAltStream = true; |
| 734 | item2.Parent = (int)prevIndex; | 736 | item2.Parent = (int)prevIndex; |
| @@ -1531,6 +1533,7 @@ HRESULT CDatabase::FillAndCheck(const CObjectVector<CVolume> &volumes) | |||
| 1531 | if (!r.IsSolidBig() || Solids[r.SolidIndex].FirstSmallStream < 0) | 1533 | if (!r.IsSolidBig() || Solids[r.SolidIndex].FirstSmallStream < 0) |
| 1532 | { | 1534 | { |
| 1533 | CItem item; | 1535 | CItem item; |
| 1536 | item.Construct(); | ||
| 1534 | item.Offset = 0; | 1537 | item.Offset = 0; |
| 1535 | item.StreamIndex = (int)i; | 1538 | item.StreamIndex = (int)i; |
| 1536 | item.ImageIndex = -1; | 1539 | item.ImageIndex = -1; |
diff --git a/CPP/7zip/Archive/Wim/WimIn.h b/CPP/7zip/Archive/Wim/WimIn.h index 571f414..ae7cd6b 100644 --- a/CPP/7zip/Archive/Wim/WimIn.h +++ b/CPP/7zip/Archive/Wim/WimIn.h | |||
| @@ -347,15 +347,16 @@ struct CItem | |||
| 347 | 347 | ||
| 348 | bool HasMetadata() const { return ImageIndex >= 0; } | 348 | bool HasMetadata() const { return ImageIndex >= 0; } |
| 349 | 349 | ||
| 350 | CItem(): | 350 | void Construct() |
| 351 | IndexInSorted(-1), | 351 | { |
| 352 | StreamIndex(-1), | 352 | IndexInSorted = -1; |
| 353 | Parent(-1), | 353 | StreamIndex = -1; |
| 354 | IsDir(false), | 354 | Parent = -1; |
| 355 | IsAltStream(false), | 355 | IsDir = false; |
| 356 | DirLevel(0), | 356 | IsAltStream = false; |
| 357 | SubDirOffset(0) | 357 | DirLevel = 0; |
| 358 | {} | 358 | SubDirOffset = 0; |
| 359 | } | ||
| 359 | }; | 360 | }; |
| 360 | 361 | ||
| 361 | struct CImage | 362 | struct CImage |
diff --git a/CPP/7zip/Common/CreateCoder.cpp b/CPP/7zip/Common/CreateCoder.cpp index 93113a0..67873d1 100644 --- a/CPP/7zip/Common/CreateCoder.cpp +++ b/CPP/7zip/Common/CreateCoder.cpp | |||
| @@ -2,7 +2,7 @@ | |||
| 2 | 2 | ||
| 3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
| 4 | 4 | ||
| 5 | #include "../../Windows/Defs.h" | 5 | #include "../../Windows/WinDefs.h" |
| 6 | #include "../../Windows/PropVariant.h" | 6 | #include "../../Windows/PropVariant.h" |
| 7 | 7 | ||
| 8 | #include "CreateCoder.h" | 8 | #include "CreateCoder.h" |
diff --git a/CPP/7zip/Common/MethodProps.h b/CPP/7zip/Common/MethodProps.h index be108fa..f7ba569 100644 --- a/CPP/7zip/Common/MethodProps.h +++ b/CPP/7zip/Common/MethodProps.h | |||
| @@ -6,8 +6,7 @@ | |||
| 6 | #include "../../Common/MyString.h" | 6 | #include "../../Common/MyString.h" |
| 7 | #include "../../Common/Defs.h" | 7 | #include "../../Common/Defs.h" |
| 8 | 8 | ||
| 9 | #include "../../Windows/Defs.h" | 9 | #include "../../Windows/WinDefs.h" |
| 10 | |||
| 11 | #include "../../Windows/PropVariant.h" | 10 | #include "../../Windows/PropVariant.h" |
| 12 | 11 | ||
| 13 | #include "../ICoder.h" | 12 | #include "../ICoder.h" |
diff --git a/CPP/7zip/Common/PropId.cpp b/CPP/7zip/Common/PropId.cpp index 6117b0e..b00ad81 100644 --- a/CPP/7zip/Common/PropId.cpp +++ b/CPP/7zip/Common/PropId.cpp | |||
| @@ -3,10 +3,8 @@ | |||
| 3 | #include "StdAfx.h" | 3 | #include "StdAfx.h" |
| 4 | 4 | ||
| 5 | #include "../../Common/MyWindows.h" | 5 | #include "../../Common/MyWindows.h" |
| 6 | |||
| 7 | #include "../PropID.h" | 6 | #include "../PropID.h" |
| 8 | 7 | ||
| 9 | // VARTYPE | ||
| 10 | const Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED] = | 8 | const Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED] = |
| 11 | { | 9 | { |
| 12 | VT_EMPTY, | 10 | VT_EMPTY, |
| @@ -84,7 +82,7 @@ const Byte k7z_PROPID_To_VARTYPE[kpid_NUM_DEFINED] = | |||
| 84 | VT_UI4, | 82 | VT_UI4, |
| 85 | VT_BSTR, | 83 | VT_BSTR, |
| 86 | VT_UI8, | 84 | VT_UI8, |
| 87 | VT_UI8, | 85 | VT_UI4, // kpidNumAltStreams |
| 88 | VT_UI8, | 86 | VT_UI8, |
| 89 | VT_UI8, | 87 | VT_UI8, |
| 90 | VT_UI8, | 88 | VT_UI8, |
diff --git a/CPP/7zip/Compress/CodecExports.cpp b/CPP/7zip/Compress/CodecExports.cpp index e37ae14..70be760 100644 --- a/CPP/7zip/Compress/CodecExports.cpp +++ b/CPP/7zip/Compress/CodecExports.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #include "../../Common/ComTry.h" | 8 | #include "../../Common/ComTry.h" |
| 9 | #include "../../Common/MyCom.h" | 9 | #include "../../Common/MyCom.h" |
| 10 | 10 | ||
| 11 | #include "../../Windows/Defs.h" | 11 | #include "../../Windows/WinDefs.h" |
| 12 | #include "../../Windows/PropVariant.h" | 12 | #include "../../Windows/PropVariant.h" |
| 13 | 13 | ||
| 14 | #include "../ICoder.h" | 14 | #include "../ICoder.h" |
diff --git a/CPP/7zip/UI/Agent/AgentOut.cpp b/CPP/7zip/UI/Agent/AgentOut.cpp index 903cde2..265b943 100644 --- a/CPP/7zip/UI/Agent/AgentOut.cpp +++ b/CPP/7zip/UI/Agent/AgentOut.cpp | |||
| @@ -497,6 +497,7 @@ HRESULT CAgent::CreateFolder(ISequentialOutStream *outArchiveStream, | |||
| 497 | updatePairs.Add(up2); | 497 | updatePairs.Add(up2); |
| 498 | } | 498 | } |
| 499 | CUpdatePair2 up2; | 499 | CUpdatePair2 up2; |
| 500 | up2.Construct(); | ||
| 500 | up2.NewData = up2.NewProps = true; | 501 | up2.NewData = up2.NewProps = true; |
| 501 | up2.UseArcProps = false; | 502 | up2.UseArcProps = false; |
| 502 | up2.DirIndex = 0; | 503 | up2.DirIndex = 0; |
diff --git a/CPP/7zip/UI/Agent/AgentProxy.cpp b/CPP/7zip/UI/Agent/AgentProxy.cpp index d04ddab..c8edd19 100644 --- a/CPP/7zip/UI/Agent/AgentProxy.cpp +++ b/CPP/7zip/UI/Agent/AgentProxy.cpp | |||
| @@ -233,11 +233,26 @@ void CProxyArc::CalculateSizes(unsigned dirIndex, IInArchive *archive) | |||
| 233 | } | 233 | } |
| 234 | } | 234 | } |
| 235 | 235 | ||
| 236 | |||
| 237 | void CProxyArc::FreeFiles() | ||
| 238 | { | ||
| 239 | const unsigned numFiles = NumFiles; | ||
| 240 | NumFiles = 0; | ||
| 241 | CProxyFile *f = Files; | ||
| 242 | for (unsigned i = 0; i < numFiles; i++, f++) | ||
| 243 | if (f->NeedDeleteName) | ||
| 244 | delete [](wchar_t *)(void *)f->Name; | ||
| 245 | delete []Files; | ||
| 246 | Files = NULL; | ||
| 247 | } | ||
| 248 | |||
| 249 | static const UInt32 k_NumFiles_Max = 0x7fffffff - 15; | ||
| 250 | |||
| 236 | HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) | 251 | HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) |
| 237 | { | 252 | { |
| 238 | // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) { | 253 | // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) { |
| 239 | 254 | ||
| 240 | Files.Free(); | 255 | FreeFiles(); |
| 241 | Dirs.Clear(); | 256 | Dirs.Clear(); |
| 242 | 257 | ||
| 243 | Dirs.AddNew(); | 258 | Dirs.AddNew(); |
| @@ -245,11 +260,15 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) | |||
| 245 | 260 | ||
| 246 | UInt32 numItems; | 261 | UInt32 numItems; |
| 247 | RINOK(archive->GetNumberOfItems(&numItems)) | 262 | RINOK(archive->GetNumberOfItems(&numItems)) |
| 263 | if (numItems > k_NumFiles_Max) | ||
| 264 | return E_OUTOFMEMORY; | ||
| 248 | 265 | ||
| 249 | if (progress) | 266 | if (progress) |
| 250 | RINOK(progress->SetTotal(numItems)) | 267 | RINOK(progress->SetTotal(numItems)) |
| 251 | 268 | ||
| 252 | Files.Alloc(numItems); | 269 | Z7_ARRAY_NEW(Files, CProxyFile, numItems) |
| 270 | memset(Files, 0, (size_t)numItems * sizeof(*Files)); | ||
| 271 | NumFiles = numItems; | ||
| 253 | 272 | ||
| 254 | UString path; | 273 | UString path; |
| 255 | UString name; | 274 | UString name; |
| @@ -375,6 +394,7 @@ HRESULT CProxyArc::Load(const CArc &arc, IProgress *progress) | |||
| 375 | RINOK(Archive_IsItem_Dir(archive, i, isDir)) | 394 | RINOK(Archive_IsItem_Dir(archive, i, isDir)) |
| 376 | 395 | ||
| 377 | CProxyFile &f = Files[i]; | 396 | CProxyFile &f = Files[i]; |
| 397 | f.Construct(); // optional because memset() in code above | ||
| 378 | 398 | ||
| 379 | f.NameLen = len - namePos; | 399 | f.NameLen = len - namePos; |
| 380 | s += namePos; | 400 | s += namePos; |
| @@ -579,6 +599,19 @@ bool CProxyArc2::IsThere_SubDir(unsigned dirIndex, const UString &name) const | |||
| 579 | return false; | 599 | return false; |
| 580 | } | 600 | } |
| 581 | 601 | ||
| 602 | |||
| 603 | void CProxyArc2::FreeFiles() | ||
| 604 | { | ||
| 605 | const unsigned numFiles = NumFiles; | ||
| 606 | NumFiles = 0; | ||
| 607 | CProxyFile2 *f = Files; | ||
| 608 | for (unsigned i = 0; i < numFiles; i++, f++) | ||
| 609 | if (f->NeedDeleteName) | ||
| 610 | delete [](wchar_t *)(void *)f->Name; | ||
| 611 | delete []Files; | ||
| 612 | Files = NULL; | ||
| 613 | } | ||
| 614 | |||
| 582 | HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) | 615 | HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) |
| 583 | { | 616 | { |
| 584 | if (!arc.GetRawProps) | 617 | if (!arc.GetRawProps) |
| @@ -587,12 +620,14 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) | |||
| 587 | // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) { | 620 | // DWORD tickCount = GetTickCount(); for (int ttt = 0; ttt < 1; ttt++) { |
| 588 | 621 | ||
| 589 | Dirs.Clear(); | 622 | Dirs.Clear(); |
| 590 | Files.Free(); | 623 | FreeFiles(); |
| 591 | 624 | ||
| 592 | IInArchive *archive = arc.Archive; | 625 | IInArchive *archive = arc.Archive; |
| 593 | 626 | ||
| 594 | UInt32 numItems; | 627 | UInt32 numItems; |
| 595 | RINOK(archive->GetNumberOfItems(&numItems)) | 628 | RINOK(archive->GetNumberOfItems(&numItems)) |
| 629 | if (numItems > k_NumFiles_Max) | ||
| 630 | return E_OUTOFMEMORY; | ||
| 596 | if (progress) | 631 | if (progress) |
| 597 | RINOK(progress->SetTotal(numItems)) | 632 | RINOK(progress->SetTotal(numItems)) |
| 598 | UString fileName; | 633 | UString fileName; |
| @@ -609,7 +644,9 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) | |||
| 609 | dir.PathPrefix = ':'; | 644 | dir.PathPrefix = ':'; |
| 610 | } | 645 | } |
| 611 | 646 | ||
| 612 | Files.Alloc(numItems); | 647 | Z7_ARRAY_NEW(Files, CProxyFile2, numItems) |
| 648 | memset(Files, 0, (size_t)numItems * sizeof(*Files)); | ||
| 649 | NumFiles = numItems; | ||
| 613 | 650 | ||
| 614 | UString tempUString; | 651 | UString tempUString; |
| 615 | AString tempAString; | 652 | AString tempAString; |
| @@ -619,11 +656,12 @@ HRESULT CProxyArc2::Load(const CArc &arc, IProgress *progress) | |||
| 619 | { | 656 | { |
| 620 | if (progress && (i & 0xFFFFF) == 0) | 657 | if (progress && (i & 0xFFFFF) == 0) |
| 621 | { | 658 | { |
| 622 | UInt64 currentItemIndex = i; | 659 | const UInt64 currentItemIndex = i; |
| 623 | RINOK(progress->SetCompleted(¤tItemIndex)) | 660 | RINOK(progress->SetCompleted(¤tItemIndex)) |
| 624 | } | 661 | } |
| 625 | 662 | ||
| 626 | CProxyFile2 &file = Files[i]; | 663 | CProxyFile2 &file = Files[i]; |
| 664 | file.Construct(); | ||
| 627 | 665 | ||
| 628 | const void *p; | 666 | const void *p; |
| 629 | UInt32 size; | 667 | UInt32 size; |
diff --git a/CPP/7zip/UI/Agent/AgentProxy.h b/CPP/7zip/UI/Agent/AgentProxy.h index c24dd91..c6736a8 100644 --- a/CPP/7zip/UI/Agent/AgentProxy.h +++ b/CPP/7zip/UI/Agent/AgentProxy.h | |||
| @@ -11,8 +11,12 @@ struct CProxyFile | |||
| 11 | unsigned NameLen; | 11 | unsigned NameLen; |
| 12 | bool NeedDeleteName; | 12 | bool NeedDeleteName; |
| 13 | 13 | ||
| 14 | CProxyFile(): Name(NULL), NameLen(0), NeedDeleteName(false) {} | 14 | void Construct() |
| 15 | ~CProxyFile() { if (NeedDeleteName) delete [](wchar_t *)(void *)Name; } // delete [](wchar_t *)Name; | 15 | { |
| 16 | Name = NULL; | ||
| 17 | NameLen = 0; | ||
| 18 | NeedDeleteName = false; | ||
| 19 | } | ||
| 16 | }; | 20 | }; |
| 17 | 21 | ||
| 18 | const unsigned k_Proxy_RootDirIndex = 0; | 22 | const unsigned k_Proxy_RootDirIndex = 0; |
| @@ -47,9 +51,14 @@ class CProxyArc | |||
| 47 | 51 | ||
| 48 | void CalculateSizes(unsigned dirIndex, IInArchive *archive); | 52 | void CalculateSizes(unsigned dirIndex, IInArchive *archive); |
| 49 | unsigned AddDir(unsigned dirIndex, int arcIndex, const UString &name); | 53 | unsigned AddDir(unsigned dirIndex, int arcIndex, const UString &name); |
| 54 | void FreeFiles(); | ||
| 50 | public: | 55 | public: |
| 51 | CObjectVector<CProxyDir> Dirs; // Dirs[0] - root | 56 | CObjectVector<CProxyDir> Dirs; // Dirs[0] - root |
| 52 | CObjArray<CProxyFile> Files; // all items from archive in same order | 57 | CProxyFile *Files; // all items from archive in same order |
| 58 | unsigned NumFiles; | ||
| 59 | |||
| 60 | CProxyArc(): Files(NULL), NumFiles(0) {} | ||
| 61 | ~CProxyArc() { FreeFiles(); } | ||
| 53 | 62 | ||
| 54 | // returns index in Dirs[], or -1, | 63 | // returns index in Dirs[], or -1, |
| 55 | int FindSubDir(unsigned dirIndex, const wchar_t *name) const; | 64 | int FindSubDir(unsigned dirIndex, const wchar_t *name) const; |
| @@ -83,17 +92,17 @@ struct CProxyFile2 | |||
| 83 | int GetDirIndex(bool forAltStreams) const { return forAltStreams ? AltDirIndex : DirIndex; } | 92 | int GetDirIndex(bool forAltStreams) const { return forAltStreams ? AltDirIndex : DirIndex; } |
| 84 | 93 | ||
| 85 | bool IsDir() const { return DirIndex != -1; } | 94 | bool IsDir() const { return DirIndex != -1; } |
| 86 | CProxyFile2(): | 95 | |
| 87 | DirIndex(-1), AltDirIndex(-1), Parent(-1), | 96 | void Construct() |
| 88 | Name(NULL), NameLen(0), | ||
| 89 | NeedDeleteName(false), | ||
| 90 | Ignore(false), | ||
| 91 | IsAltStream(false) | ||
| 92 | {} | ||
| 93 | ~CProxyFile2() | ||
| 94 | { | 97 | { |
| 95 | if (NeedDeleteName) | 98 | DirIndex = -1; |
| 96 | delete [](wchar_t *)(void *)Name; | 99 | AltDirIndex = -1; |
| 100 | Parent = -1; | ||
| 101 | Name = NULL; | ||
| 102 | NameLen = 0; | ||
| 103 | NeedDeleteName = false; | ||
| 104 | Ignore = false; | ||
| 105 | IsAltStream = false; | ||
| 97 | } | 106 | } |
| 98 | }; | 107 | }; |
| 99 | 108 | ||
| @@ -110,8 +119,6 @@ struct CProxyDir2 | |||
| 110 | UInt32 NumSubFiles; | 119 | UInt32 NumSubFiles; |
| 111 | 120 | ||
| 112 | CProxyDir2(): ArcIndex(-1) {} | 121 | CProxyDir2(): ArcIndex(-1) {} |
| 113 | void AddFileSubItem(UInt32 index, const UString &name); | ||
| 114 | void Clear(); | ||
| 115 | }; | 122 | }; |
| 116 | 123 | ||
| 117 | const unsigned k_Proxy2_RootDirIndex = k_Proxy_RootDirIndex; | 124 | const unsigned k_Proxy2_RootDirIndex = k_Proxy_RootDirIndex; |
| @@ -123,10 +130,15 @@ class CProxyArc2 | |||
| 123 | void CalculateSizes(unsigned dirIndex, IInArchive *archive); | 130 | void CalculateSizes(unsigned dirIndex, IInArchive *archive); |
| 124 | // AddRealIndices_of_Dir DOES NOT ADD item itself represented by dirIndex | 131 | // AddRealIndices_of_Dir DOES NOT ADD item itself represented by dirIndex |
| 125 | void AddRealIndices_of_Dir(unsigned dirIndex, bool includeAltStreams, CUIntVector &realIndices) const; | 132 | void AddRealIndices_of_Dir(unsigned dirIndex, bool includeAltStreams, CUIntVector &realIndices) const; |
| 133 | void FreeFiles(); | ||
| 126 | public: | 134 | public: |
| 127 | CObjectVector<CProxyDir2> Dirs; // Dirs[0] - root folder | 135 | CObjectVector<CProxyDir2> Dirs; // Dirs[0] - root folder |
| 128 | // Dirs[1] - for alt streams of root dir | 136 | // Dirs[1] - for alt streams of root dir |
| 129 | CObjArray<CProxyFile2> Files; // all items from archive in same order | 137 | CProxyFile2 *Files; // all items from archive in same order |
| 138 | unsigned NumFiles; | ||
| 139 | |||
| 140 | CProxyArc2(): Files(NULL), NumFiles(0) {} | ||
| 141 | ~CProxyArc2() { FreeFiles(); } | ||
| 130 | 142 | ||
| 131 | bool IsThere_SubDir(unsigned dirIndex, const UString &name) const; | 143 | bool IsThere_SubDir(unsigned dirIndex, const UString &name) const; |
| 132 | 144 | ||
diff --git a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp index 6631629..7f6da0c 100644 --- a/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp +++ b/CPP/7zip/UI/Common/ArchiveExtractCallback.cpp | |||
| @@ -1842,6 +1842,11 @@ Z7_COM7F_IMF(CArchiveExtractCallback::GetStream(UInt32 index, ISequentialOutStre | |||
| 1842 | outStreamLoc = new CStdOutFileStream; | 1842 | outStreamLoc = new CStdOutFileStream; |
| 1843 | else | 1843 | else |
| 1844 | { | 1844 | { |
| 1845 | if (_isSplit) | ||
| 1846 | { | ||
| 1847 | RINOK(PrepareOperation(askExtractMode)) | ||
| 1848 | return SetOperationResult(NArchive::NExtract::NOperationResult::kUnsupportedMethod); | ||
| 1849 | } | ||
| 1845 | bool needExit = true; | 1850 | bool needExit = true; |
| 1846 | RINOK(GetExtractStream(outStreamLoc, needExit)) | 1851 | RINOK(GetExtractStream(outStreamLoc, needExit)) |
| 1847 | if (needExit) | 1852 | if (needExit) |
| @@ -2674,6 +2679,7 @@ Z7_COM7F_IMF(CArchiveExtractCallback::SetOperationResult(Int32 opRes)) | |||
| 2674 | { | 2679 | { |
| 2675 | COM_TRY_BEGIN | 2680 | COM_TRY_BEGIN |
| 2676 | 2681 | ||
| 2682 | // if (_isSplit) opRes = NArchive::NExtract::NOperationResult::kUnsupportedMethod; | ||
| 2677 | // printf("\nCArchiveExtractCallback::SetOperationResult: %d %s\n", opRes, GetAnsiString(_diskFilePath)); | 2683 | // printf("\nCArchiveExtractCallback::SetOperationResult: %d %s\n", opRes, GetAnsiString(_diskFilePath)); |
| 2678 | 2684 | ||
| 2679 | #ifndef Z7_SFX | 2685 | #ifndef Z7_SFX |
diff --git a/CPP/7zip/UI/Common/LoadCodecs.cpp b/CPP/7zip/UI/Common/LoadCodecs.cpp index e71158c..c944ee9 100644 --- a/CPP/7zip/UI/Common/LoadCodecs.cpp +++ b/CPP/7zip/UI/Common/LoadCodecs.cpp | |||
| @@ -211,10 +211,11 @@ static FString GetBaseFolderPrefixFromRegistry() | |||
| 211 | && !NFind::DoesFileOrDirExist(moduleFolderPrefix + kFormatsFolderName)) | 211 | && !NFind::DoesFileOrDirExist(moduleFolderPrefix + kFormatsFolderName)) |
| 212 | { | 212 | { |
| 213 | FString path; | 213 | FString path; |
| 214 | if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPath2Value, path)) return path; | 214 | if ( ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPath2Value, path) |
| 215 | if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPath2Value, path)) return path; | 215 | || ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPath2Value, path) |
| 216 | if (ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPathValue, path)) return path; | 216 | || ReadPathFromRegistry(HKEY_CURRENT_USER, kProgramPathValue, path) |
| 217 | if (ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPathValue, path)) return path; | 217 | || ReadPathFromRegistry(HKEY_LOCAL_MACHINE, kProgramPathValue, path)) |
| 218 | moduleFolderPrefix = path; | ||
| 218 | } | 219 | } |
| 219 | #endif | 220 | #endif |
| 220 | 221 | ||
diff --git a/CPP/7zip/UI/Common/UpdatePair.cpp b/CPP/7zip/UI/Common/UpdatePair.cpp index 99b0aaf..8fc5615 100644 --- a/CPP/7zip/UI/Common/UpdatePair.cpp +++ b/CPP/7zip/UI/Common/UpdatePair.cpp | |||
| @@ -196,6 +196,7 @@ void GetUpdatePairInfoList( | |||
| 196 | while (dirIndex < numDirItems || arcIndex < numArcItems) | 196 | while (dirIndex < numDirItems || arcIndex < numArcItems) |
| 197 | { | 197 | { |
| 198 | CUpdatePair pair; | 198 | CUpdatePair pair; |
| 199 | pair.Construct(); | ||
| 199 | 200 | ||
| 200 | int dirIndex2 = -1; | 201 | int dirIndex2 = -1; |
| 201 | int arcIndex2 = -1; | 202 | int arcIndex2 = -1; |
diff --git a/CPP/7zip/UI/Common/UpdatePair.h b/CPP/7zip/UI/Common/UpdatePair.h index 13228b0..a2855c4 100644 --- a/CPP/7zip/UI/Common/UpdatePair.h +++ b/CPP/7zip/UI/Common/UpdatePair.h | |||
| @@ -15,7 +15,7 @@ struct CUpdatePair | |||
| 15 | int DirIndex; | 15 | int DirIndex; |
| 16 | int HostIndex; // >= 0 for alt streams only, contains index of host pair | 16 | int HostIndex; // >= 0 for alt streams only, contains index of host pair |
| 17 | 17 | ||
| 18 | CUpdatePair(): ArcIndex(-1), DirIndex(-1), HostIndex(-1) {} | 18 | void Construct() { ArcIndex = -1; DirIndex = -1; HostIndex = -1; } |
| 19 | }; | 19 | }; |
| 20 | 20 | ||
| 21 | void GetUpdatePairInfoList( | 21 | void GetUpdatePairInfoList( |
diff --git a/CPP/7zip/UI/Common/UpdateProduce.cpp b/CPP/7zip/UI/Common/UpdateProduce.cpp index 88d2501..9b66d36 100644 --- a/CPP/7zip/UI/Common/UpdateProduce.cpp +++ b/CPP/7zip/UI/Common/UpdateProduce.cpp | |||
| @@ -19,6 +19,7 @@ void UpdateProduce( | |||
| 19 | const CUpdatePair &pair = updatePairs[i]; | 19 | const CUpdatePair &pair = updatePairs[i]; |
| 20 | 20 | ||
| 21 | CUpdatePair2 up2; | 21 | CUpdatePair2 up2; |
| 22 | up2.Construct(); | ||
| 22 | up2.DirIndex = pair.DirIndex; | 23 | up2.DirIndex = pair.DirIndex; |
| 23 | up2.ArcIndex = pair.ArcIndex; | 24 | up2.ArcIndex = pair.ArcIndex; |
| 24 | up2.NewData = up2.NewProps = true; | 25 | up2.NewData = up2.NewProps = true; |
diff --git a/CPP/7zip/UI/Common/UpdateProduce.h b/CPP/7zip/UI/Common/UpdateProduce.h index 9db6c1e..3d16381 100644 --- a/CPP/7zip/UI/Common/UpdateProduce.h +++ b/CPP/7zip/UI/Common/UpdateProduce.h | |||
| @@ -19,28 +19,28 @@ struct CUpdatePair2 | |||
| 19 | bool IsMainRenameItem; | 19 | bool IsMainRenameItem; |
| 20 | bool IsSameTime; | 20 | bool IsSameTime; |
| 21 | 21 | ||
| 22 | void Construct() | ||
| 23 | { | ||
| 24 | NewData = false; | ||
| 25 | NewProps = false; | ||
| 26 | UseArcProps = false; | ||
| 27 | IsAnti = false; | ||
| 28 | DirIndex = -1; | ||
| 29 | ArcIndex = -1; | ||
| 30 | NewNameIndex = -1; | ||
| 31 | IsMainRenameItem = false; | ||
| 32 | IsSameTime = false; | ||
| 33 | } | ||
| 34 | |||
| 22 | void SetAs_NoChangeArcItem(unsigned arcIndex) // int | 35 | void SetAs_NoChangeArcItem(unsigned arcIndex) // int |
| 23 | { | 36 | { |
| 24 | NewData = NewProps = false; | 37 | Construct(); |
| 25 | UseArcProps = true; | 38 | UseArcProps = true; |
| 26 | IsAnti = false; | ||
| 27 | ArcIndex = (int)arcIndex; | 39 | ArcIndex = (int)arcIndex; |
| 28 | } | 40 | } |
| 29 | 41 | ||
| 30 | bool ExistOnDisk() const { return DirIndex != -1; } | 42 | bool ExistOnDisk() const { return DirIndex != -1; } |
| 31 | bool ExistInArchive() const { return ArcIndex != -1; } | 43 | bool ExistInArchive() const { return ArcIndex != -1; } |
| 32 | |||
| 33 | CUpdatePair2(): | ||
| 34 | NewData(false), | ||
| 35 | NewProps(false), | ||
| 36 | UseArcProps(false), | ||
| 37 | IsAnti(false), | ||
| 38 | DirIndex(-1), | ||
| 39 | ArcIndex(-1), | ||
| 40 | NewNameIndex(-1), | ||
| 41 | IsMainRenameItem(false), | ||
| 42 | IsSameTime(false) | ||
| 43 | {} | ||
| 44 | }; | 44 | }; |
| 45 | 45 | ||
| 46 | Z7_PURE_INTERFACES_BEGIN | 46 | Z7_PURE_INTERFACES_BEGIN |
diff --git a/CPP/7zip/UI/Far/FarUtils.cpp b/CPP/7zip/UI/Far/FarUtils.cpp index 3c33d8e..1d331e9 100644 --- a/CPP/7zip/UI/Far/FarUtils.cpp +++ b/CPP/7zip/UI/Far/FarUtils.cpp | |||
| @@ -8,7 +8,7 @@ | |||
| 8 | #ifndef UNDER_CE | 8 | #ifndef UNDER_CE |
| 9 | #include "../../../Windows/Console.h" | 9 | #include "../../../Windows/Console.h" |
| 10 | #endif | 10 | #endif |
| 11 | #include "../../../Windows/Defs.h" | 11 | #include "../../../Windows/WinDefs.h" |
| 12 | #include "../../../Windows/ErrorMsg.h" | 12 | #include "../../../Windows/ErrorMsg.h" |
| 13 | 13 | ||
| 14 | #include "FarUtils.h" | 14 | #include "FarUtils.h" |
| @@ -259,17 +259,15 @@ void CStartupInfo::SetRegKeyValue(HKEY parentKey, const char *keyName, | |||
| 259 | regKey.SetValue(valueName, value); | 259 | regKey.SetValue(valueName, value); |
| 260 | } | 260 | } |
| 261 | 261 | ||
| 262 | /* | ||
| 262 | CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, | 263 | CSysString CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, |
| 263 | LPCTSTR valueName, const CSysString &valueDefault) const | 264 | LPCTSTR valueName, const CSysString &valueDefault) const |
| 264 | { | 265 | { |
| 265 | NRegistry::CKey regKey; | ||
| 266 | if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS) | ||
| 267 | return valueDefault; | ||
| 268 | |||
| 269 | CSysString value; | 266 | CSysString value; |
| 270 | if (regKey.QueryValue(valueName, value) != ERROR_SUCCESS) | 267 | NRegistry::CKey regKey; |
| 271 | return valueDefault; | 268 | if (OpenRegKey(parentKey, keyName, regKey) != ERROR_SUCCESS |
| 272 | 269 | || regKey.QueryValue(valueName, value) != ERROR_SUCCESS) | |
| 270 | value = valueDefault; | ||
| 273 | return value; | 271 | return value; |
| 274 | } | 272 | } |
| 275 | 273 | ||
| @@ -286,6 +284,7 @@ UInt32 CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, | |||
| 286 | 284 | ||
| 287 | return value; | 285 | return value; |
| 288 | } | 286 | } |
| 287 | */ | ||
| 289 | 288 | ||
| 290 | bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, | 289 | bool CStartupInfo::QueryRegKeyValue(HKEY parentKey, const char *keyName, |
| 291 | LPCTSTR valueName, bool valueDefault) const | 290 | LPCTSTR valueName, bool valueDefault) const |
diff --git a/CPP/7zip/UI/Far/Plugin.cpp b/CPP/7zip/UI/Far/Plugin.cpp index b7f91d6..f04f712 100644 --- a/CPP/7zip/UI/Far/Plugin.cpp +++ b/CPP/7zip/UI/Far/Plugin.cpp | |||
| @@ -143,8 +143,13 @@ void CPlugin::ReadPluginPanelItem(PluginPanelItem &panelItem, UInt32 itemIndex) | |||
| 143 | panelItem.Reserved[1] = 0; | 143 | panelItem.Reserved[1] = 0; |
| 144 | } | 144 | } |
| 145 | 145 | ||
| 146 | |||
| 147 | static const UInt32 k_NumFiles_Max = 0x7fffffff - 15; | ||
| 148 | |||
| 146 | int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode) | 149 | int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opMode) |
| 147 | { | 150 | { |
| 151 | *panelItems = NULL; | ||
| 152 | *itemsNumber = 0; | ||
| 148 | // CScreenRestorer screenRestorer; | 153 | // CScreenRestorer screenRestorer; |
| 149 | if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0) | 154 | if ((opMode & OPM_SILENT) == 0 && (opMode & OPM_FIND ) == 0) |
| 150 | { | 155 | { |
| @@ -160,8 +165,13 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opM | |||
| 160 | } | 165 | } |
| 161 | 166 | ||
| 162 | UInt32 numItems; | 167 | UInt32 numItems; |
| 163 | _folder->GetNumberOfItems(&numItems); | 168 | if (_folder->GetNumberOfItems(&numItems) != S_OK) |
| 164 | *panelItems = new PluginPanelItem[numItems]; | 169 | return FALSE; |
| 170 | if (numItems > k_NumFiles_Max) | ||
| 171 | return FALSE; | ||
| 172 | |||
| 173 | Z7_ARRAY_NEW(*panelItems, PluginPanelItem, numItems) | ||
| 174 | memset(*panelItems, 0, (size_t)numItems * sizeof(PluginPanelItem)); | ||
| 165 | try | 175 | try |
| 166 | { | 176 | { |
| 167 | for (UInt32 i = 0; i < numItems; i++) | 177 | for (UInt32 i = 0; i < numItems; i++) |
| @@ -174,6 +184,7 @@ int CPlugin::GetFindData(PluginPanelItem **panelItems, int *itemsNumber, int opM | |||
| 174 | catch(...) | 184 | catch(...) |
| 175 | { | 185 | { |
| 176 | delete [](*panelItems); | 186 | delete [](*panelItems); |
| 187 | *panelItems = NULL; | ||
| 177 | throw; | 188 | throw; |
| 178 | } | 189 | } |
| 179 | *itemsNumber = (int)numItems; | 190 | *itemsNumber = (int)numItems; |
diff --git a/CPP/7zip/UI/FileManager/BrowseDialog2.cpp b/CPP/7zip/UI/FileManager/BrowseDialog2.cpp index 9f083c5..f8bfcb5 100644 --- a/CPP/7zip/UI/FileManager/BrowseDialog2.cpp +++ b/CPP/7zip/UI/FileManager/BrowseDialog2.cpp | |||
| @@ -95,15 +95,16 @@ struct CBrowseItem | |||
| 95 | UInt32 NumRootItems; | 95 | UInt32 NumRootItems; |
| 96 | UInt64 Size; | 96 | UInt64 Size; |
| 97 | 97 | ||
| 98 | CBrowseItem(): | 98 | void Construct() |
| 99 | // MainFileIndex(0), | 99 | { |
| 100 | SubFileIndex(-1), | 100 | // MainFileIndex = 0; |
| 101 | WasInterrupted(false), | 101 | SubFileIndex = -1; |
| 102 | NumFiles(0), | 102 | WasInterrupted = false; |
| 103 | NumDirs(0), | 103 | NumFiles = 0; |
| 104 | NumRootItems(0), | 104 | NumDirs = 0; |
| 105 | Size(0) | 105 | NumRootItems = 0; |
| 106 | {} | 106 | Size = 0; |
| 107 | } | ||
| 107 | }; | 108 | }; |
| 108 | 109 | ||
| 109 | 110 | ||
| @@ -114,6 +115,10 @@ struct CBrowseEnumerator | |||
| 114 | CFileInfo fi_SubFile; | 115 | CFileInfo fi_SubFile; |
| 115 | CBrowseItem bi; | 116 | CBrowseItem bi; |
| 116 | 117 | ||
| 118 | CBrowseEnumerator() | ||
| 119 | { | ||
| 120 | bi.Construct(); | ||
| 121 | } | ||
| 117 | void Enumerate(unsigned level); | 122 | void Enumerate(unsigned level); |
| 118 | bool NeedInterrupt() const | 123 | bool NeedInterrupt() const |
| 119 | { | 124 | { |
| @@ -1504,6 +1509,7 @@ HRESULT CBrowseDialog2::Reload(const UString &pathPrefix, const UStringVector &s | |||
| 1504 | if (d.Len() < 2 || d.Back() != '\\') | 1509 | if (d.Len() < 2 || d.Back() != '\\') |
| 1505 | return E_FAIL; | 1510 | return E_FAIL; |
| 1506 | CBrowseItem item; | 1511 | CBrowseItem item; |
| 1512 | item.Construct(); | ||
| 1507 | item.MainFileIndex = files.Size(); | 1513 | item.MainFileIndex = files.Size(); |
| 1508 | CFileInfo &fi = files.AddNew(); | 1514 | CFileInfo &fi = files.AddNew(); |
| 1509 | fi.SetAsDir(); | 1515 | fi.SetAsDir(); |
| @@ -1552,6 +1558,7 @@ HRESULT CBrowseDialog2::Reload(const UString &pathPrefix, const UStringVector &s | |||
| 1552 | } | 1558 | } |
| 1553 | } | 1559 | } |
| 1554 | CBrowseItem item; | 1560 | CBrowseItem item; |
| 1561 | item.Construct(); | ||
| 1555 | item.MainFileIndex = files.Size(); | 1562 | item.MainFileIndex = files.Size(); |
| 1556 | item.Size = fi.Size; | 1563 | item.Size = fi.Size; |
| 1557 | files.Add(fi); | 1564 | files.Add(fi); |
diff --git a/CPP/Common/Common0.h b/CPP/Common/Common0.h index 5781a95..a6b842d 100644 --- a/CPP/Common/Common0.h +++ b/CPP/Common/Common0.h | |||
| @@ -162,7 +162,7 @@ if compiled with new GCC libstdc++, GCC libstdc++ can use: | |||
| 162 | So we can use Z7_ARRAY_NEW macro instead of new[] operator. */ | 162 | So we can use Z7_ARRAY_NEW macro instead of new[] operator. */ |
| 163 | 163 | ||
| 164 | #if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64) | 164 | #if defined(_MSC_VER) && (_MSC_VER == 1200) && !defined(_WIN64) |
| 165 | #define Z7_ARRAY_NEW(p, T, size) p = new T[((size) > 0xFFFFFFFFu / sizeof(T)) ? 0xFFFFFFFFu / sizeof(T) : (size)]; | 165 | #define Z7_ARRAY_NEW(p, T, size) p = new T[((size) > (0xFFFFFFFFu - 0x7fu) / sizeof(T)) ? (0xFFFFFFFFu - 0x7fu) / sizeof(T) : (size)]; |
| 166 | #else | 166 | #else |
| 167 | #define Z7_ARRAY_NEW(p, T, size) p = new T[size]; | 167 | #define Z7_ARRAY_NEW(p, T, size) p = new T[size]; |
| 168 | #endif | 168 | #endif |
diff --git a/CPP/Windows/Clipboard.cpp b/CPP/Windows/Clipboard.cpp index bc7e201..d39c264 100644 --- a/CPP/Windows/Clipboard.cpp +++ b/CPP/Windows/Clipboard.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include "../Common/StringConvert.h" | 9 | #include "../Common/StringConvert.h" |
| 10 | 10 | ||
| 11 | #include "Clipboard.h" | 11 | #include "Clipboard.h" |
| 12 | #include "Defs.h" | 12 | #include "WinDefs.h" |
| 13 | #include "MemoryGlobal.h" | 13 | #include "MemoryGlobal.h" |
| 14 | #include "Shell.h" | 14 | #include "Shell.h" |
| 15 | 15 | ||
diff --git a/CPP/Windows/CommonDialog.cpp b/CPP/Windows/CommonDialog.cpp index 7a92d5f..2e3f297 100644 --- a/CPP/Windows/CommonDialog.cpp +++ b/CPP/Windows/CommonDialog.cpp | |||
| @@ -13,7 +13,7 @@ | |||
| 13 | #endif | 13 | #endif |
| 14 | 14 | ||
| 15 | #include "CommonDialog.h" | 15 | #include "CommonDialog.h" |
| 16 | #include "Defs.h" | 16 | #include "WinDefs.h" |
| 17 | // #include "FileDir.h" | 17 | // #include "FileDir.h" |
| 18 | 18 | ||
| 19 | #ifndef _UNICODE | 19 | #ifndef _UNICODE |
diff --git a/CPP/Windows/Console.h b/CPP/Windows/Console.h index 818b8d4..6b494c8 100644 --- a/CPP/Windows/Console.h +++ b/CPP/Windows/Console.h | |||
| @@ -3,7 +3,7 @@ | |||
| 3 | #ifndef ZIP7_INC_WINDOWS_CONSOLE_H | 3 | #ifndef ZIP7_INC_WINDOWS_CONSOLE_H |
| 4 | #define ZIP7_INC_WINDOWS_CONSOLE_H | 4 | #define ZIP7_INC_WINDOWS_CONSOLE_H |
| 5 | 5 | ||
| 6 | #include "Defs.h" | 6 | #include "WinDefs.h" |
| 7 | 7 | ||
| 8 | namespace NWindows { | 8 | namespace NWindows { |
| 9 | namespace NConsole { | 9 | namespace NConsole { |
diff --git a/CPP/Windows/Control/ImageList.h b/CPP/Windows/Control/ImageList.h index 688f177..c10eea7 100644 --- a/CPP/Windows/Control/ImageList.h +++ b/CPP/Windows/Control/ImageList.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include <CommCtrl.h> | 6 | #include <CommCtrl.h> |
| 7 | 7 | ||
| 8 | #include "../Defs.h" | 8 | #include "../WinDefs.h" |
| 9 | 9 | ||
| 10 | namespace NWindows { | 10 | namespace NWindows { |
| 11 | namespace NControl { | 11 | namespace NControl { |
diff --git a/CPP/Windows/FileFind.h b/CPP/Windows/FileFind.h index 944bca2..9ae1115 100644 --- a/CPP/Windows/FileFind.h +++ b/CPP/Windows/FileFind.h | |||
| @@ -13,8 +13,6 @@ | |||
| 13 | #include "../Common/MyString.h" | 13 | #include "../Common/MyString.h" |
| 14 | #include "../Common/MyWindows.h" | 14 | #include "../Common/MyWindows.h" |
| 15 | 15 | ||
| 16 | #include "Defs.h" | ||
| 17 | |||
| 18 | #include "FileIO.h" | 16 | #include "FileIO.h" |
| 19 | 17 | ||
| 20 | namespace NWindows { | 18 | namespace NWindows { |
diff --git a/CPP/Windows/FileIO.h b/CPP/Windows/FileIO.h index 26edef4..a202df5 100644 --- a/CPP/Windows/FileIO.h +++ b/CPP/Windows/FileIO.h | |||
| @@ -31,7 +31,7 @@ | |||
| 31 | 31 | ||
| 32 | #include "../Windows/TimeUtils.h" | 32 | #include "../Windows/TimeUtils.h" |
| 33 | 33 | ||
| 34 | #include "Defs.h" | 34 | #include "WinDefs.h" |
| 35 | 35 | ||
| 36 | HRESULT GetLastError_noZero_HRESULT(); | 36 | HRESULT GetLastError_noZero_HRESULT(); |
| 37 | 37 | ||
diff --git a/CPP/Windows/FileSystem.cpp b/CPP/Windows/FileSystem.cpp index b402306..6cb9808 100644 --- a/CPP/Windows/FileSystem.cpp +++ b/CPP/Windows/FileSystem.cpp | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #endif | 9 | #endif |
| 10 | 10 | ||
| 11 | #include "FileSystem.h" | 11 | #include "FileSystem.h" |
| 12 | #include "Defs.h" | 12 | #include "WinDefs.h" |
| 13 | 13 | ||
| 14 | #ifndef _UNICODE | 14 | #ifndef _UNICODE |
| 15 | extern bool g_IsNT; | 15 | extern bool g_IsNT; |
diff --git a/CPP/Windows/Menu.h b/CPP/Windows/Menu.h index e1de4c4..00aa692 100644 --- a/CPP/Windows/Menu.h +++ b/CPP/Windows/Menu.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "../Common/MyWindows.h" | 6 | #include "../Common/MyWindows.h" |
| 7 | #include "../Common/MyString.h" | 7 | #include "../Common/MyString.h" |
| 8 | 8 | ||
| 9 | #include "Defs.h" | 9 | #include "WinDefs.h" |
| 10 | 10 | ||
| 11 | namespace NWindows { | 11 | namespace NWindows { |
| 12 | 12 | ||
diff --git a/CPP/Windows/ProcessUtils.h b/CPP/Windows/ProcessUtils.h index b1fce3a..34fef8d 100644 --- a/CPP/Windows/ProcessUtils.h +++ b/CPP/Windows/ProcessUtils.h | |||
| @@ -39,7 +39,7 @@ typedef PROCESS_MEMORY_COUNTERS *PPROCESS_MEMORY_COUNTERS; | |||
| 39 | 39 | ||
| 40 | #include "../Common/MyString.h" | 40 | #include "../Common/MyString.h" |
| 41 | 41 | ||
| 42 | #include "Defs.h" | 42 | #include "WinDefs.h" |
| 43 | #include "Handle.h" | 43 | #include "Handle.h" |
| 44 | 44 | ||
| 45 | namespace NWindows { | 45 | namespace NWindows { |
diff --git a/CPP/Windows/PropVariantConv.cpp b/CPP/Windows/PropVariantConv.cpp index 21a7b4e..467c0f8 100644 --- a/CPP/Windows/PropVariantConv.cpp +++ b/CPP/Windows/PropVariantConv.cpp | |||
| @@ -4,7 +4,7 @@ | |||
| 4 | 4 | ||
| 5 | #include "../Common/IntToString.h" | 5 | #include "../Common/IntToString.h" |
| 6 | 6 | ||
| 7 | #include "Defs.h" | 7 | #include "WinDefs.h" |
| 8 | #include "PropVariantConv.h" | 8 | #include "PropVariantConv.h" |
| 9 | 9 | ||
| 10 | #define UINT_TO_STR_2(c, val) { s[0] = (c); s[1] = (char)('0' + (val) / 10); s[2] = (char)('0' + (val) % 10); s += 3; } | 10 | #define UINT_TO_STR_2(c, val) { s[0] = (c); s[1] = (char)('0' + (val) / 10); s[2] = (char)('0' + (val) % 10); s += 3; } |
diff --git a/CPP/Windows/SecurityUtils.h b/CPP/Windows/SecurityUtils.h index 022a8f3..9775d09 100644 --- a/CPP/Windows/SecurityUtils.h +++ b/CPP/Windows/SecurityUtils.h | |||
| @@ -9,7 +9,7 @@ | |||
| 9 | #include <NTSecAPI.h> | 9 | #include <NTSecAPI.h> |
| 10 | #endif | 10 | #endif |
| 11 | 11 | ||
| 12 | #include "Defs.h" | 12 | #include "WinDefs.h" |
| 13 | 13 | ||
| 14 | #ifndef _UNICODE | 14 | #ifndef _UNICODE |
| 15 | 15 | ||
diff --git a/CPP/Windows/Shell.h b/CPP/Windows/Shell.h index 9e58e25..163c7d9 100644 --- a/CPP/Windows/Shell.h +++ b/CPP/Windows/Shell.h | |||
| @@ -12,7 +12,7 @@ | |||
| 12 | 12 | ||
| 13 | #include "../Common/MyString.h" | 13 | #include "../Common/MyString.h" |
| 14 | 14 | ||
| 15 | #include "Defs.h" | 15 | #include "WinDefs.h" |
| 16 | 16 | ||
| 17 | namespace NWindows { | 17 | namespace NWindows { |
| 18 | namespace NShell { | 18 | namespace NShell { |
diff --git a/CPP/Windows/Synchronization.h b/CPP/Windows/Synchronization.h index 1df84d3..25764b8 100644 --- a/CPP/Windows/Synchronization.h +++ b/CPP/Windows/Synchronization.h | |||
| @@ -7,7 +7,7 @@ | |||
| 7 | 7 | ||
| 8 | #include "../Common/MyTypes.h" | 8 | #include "../Common/MyTypes.h" |
| 9 | 9 | ||
| 10 | #include "Defs.h" | 10 | #include "WinDefs.h" |
| 11 | 11 | ||
| 12 | #ifdef _WIN32 | 12 | #ifdef _WIN32 |
| 13 | #include "Handle.h" | 13 | #include "Handle.h" |
diff --git a/CPP/Windows/Thread.h b/CPP/Windows/Thread.h index 75c1616..028267b 100644 --- a/CPP/Windows/Thread.h +++ b/CPP/Windows/Thread.h | |||
| @@ -5,7 +5,7 @@ | |||
| 5 | 5 | ||
| 6 | #include "../../C/Threads.h" | 6 | #include "../../C/Threads.h" |
| 7 | 7 | ||
| 8 | #include "Defs.h" | 8 | #include "WinDefs.h" |
| 9 | 9 | ||
| 10 | namespace NWindows { | 10 | namespace NWindows { |
| 11 | 11 | ||
diff --git a/CPP/Windows/TimeUtils.cpp b/CPP/Windows/TimeUtils.cpp index 4e3bc59..c83f75d 100644 --- a/CPP/Windows/TimeUtils.cpp +++ b/CPP/Windows/TimeUtils.cpp | |||
| @@ -7,8 +7,8 @@ | |||
| 7 | #include <time.h> | 7 | #include <time.h> |
| 8 | #endif | 8 | #endif |
| 9 | 9 | ||
| 10 | #include "Defs.h" | ||
| 11 | #include "TimeUtils.h" | 10 | #include "TimeUtils.h" |
| 11 | #include "WinDefs.h" | ||
| 12 | 12 | ||
| 13 | namespace NWindows { | 13 | namespace NWindows { |
| 14 | namespace NTime { | 14 | namespace NTime { |
diff --git a/CPP/Windows/Defs.h b/CPP/Windows/WinDefs.h index 8ab9cf5..86512d2 100644 --- a/CPP/Windows/Defs.h +++ b/CPP/Windows/WinDefs.h | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | // Windows/Defs.h | 1 | // Windows/Defs.h |
| 2 | 2 | ||
| 3 | #ifndef ZIP7_INC_WINDOWS_DEFS_H | 3 | #ifndef ZIP7_INC_WINDOWS_WIN_DEFS_H |
| 4 | #define ZIP7_INC_WINDOWS_DEFS_H | 4 | #define ZIP7_INC_WINDOWS_WIN_DEFS_H |
| 5 | 5 | ||
| 6 | #include "../Common/MyWindows.h" | 6 | #include "../Common/MyWindows.h" |
| 7 | 7 | ||
diff --git a/CPP/Windows/Window.h b/CPP/Windows/Window.h index a99143b..b0ddef9 100644 --- a/CPP/Windows/Window.h +++ b/CPP/Windows/Window.h | |||
| @@ -6,7 +6,7 @@ | |||
| 6 | #include "../Common/MyWindows.h" | 6 | #include "../Common/MyWindows.h" |
| 7 | #include "../Common/MyString.h" | 7 | #include "../Common/MyString.h" |
| 8 | 8 | ||
| 9 | #include "Defs.h" | 9 | #include "WinDefs.h" |
| 10 | 10 | ||
| 11 | #ifndef UNDER_CE | 11 | #ifndef UNDER_CE |
| 12 | #ifdef WM_CHANGEUISTATE | 12 | #ifdef WM_CHANGEUISTATE |
diff --git a/DOC/7zip.wxs b/DOC/7zip.wxs index 9ec9cf9..44e71e1 100644 --- a/DOC/7zip.wxs +++ b/DOC/7zip.wxs | |||
| @@ -1,7 +1,7 @@ | |||
| 1 | <?xml version="1.0"?> | 1 | <?xml version="1.0"?> |
| 2 | 2 | ||
| 3 | <?define VerMajor = "26" ?> | 3 | <?define VerMajor = "26" ?> |
| 4 | <?define VerMinor = "01" ?> | 4 | <?define VerMinor = "02" ?> |
| 5 | <?define VerBuild = "00" ?> | 5 | <?define VerBuild = "00" ?> |
| 6 | <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> | 6 | <?define MmVer = "$(var.VerMajor).$(var.VerMinor)" ?> |
| 7 | <?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?> | 7 | <?define MmHex = "$(var.VerMajor)$(var.VerMinor)" ?> |
diff --git a/DOC/readme.txt b/DOC/readme.txt index e0048cf..fd01e3b 100644 --- a/DOC/readme.txt +++ b/DOC/readme.txt | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | 7-Zip 26.01 Sources | 1 | 7-Zip 26.02 Sources |
| 2 | ------------------- | 2 | ------------------- |
| 3 | 3 | ||
| 4 | 7-Zip is a file archiver for Windows. | 4 | 7-Zip is a file archiver for Windows. |
diff --git a/DOC/src-history.txt b/DOC/src-history.txt index 8f507b0..7858175 100644 --- a/DOC/src-history.txt +++ b/DOC/src-history.txt | |||
| @@ -1,6 +1,11 @@ | |||
| 1 | HISTORY of the 7-Zip source code | 1 | HISTORY of the 7-Zip source code |
| 2 | -------------------------------- | 2 | -------------------------------- |
| 3 | 3 | ||
| 4 | 26.02 2026-06-25 | ||
| 5 | ------------------------- | ||
| 6 | - Some bugs and vulnerabilities were fixed. | ||
| 7 | |||
| 8 | |||
| 4 | 26.01 2026-04-27 | 9 | 26.01 2026-04-27 |
| 5 | ------------------------- | 10 | ------------------------- |
| 6 | - linux version of 7-Zip can use huge pages (2 MB pages). It can increase compression | 11 | - linux version of 7-Zip can use huge pages (2 MB pages). It can increase compression |
