| 12 | |
| 13 | |
| 14 | bool Archive::DoGetComment(Array<wchar> *CmtData) |
| 15 | { |
| 16 | #ifndef SFX_MODULE |
| 17 | uint CmtLength; |
| 18 | if (Format==RARFMT14) |
| 19 | { |
| 20 | Seek(SFXSize+SIZEOF_MAINHEAD14,SEEK_SET); |
| 21 | CmtLength=GetByte(); |
| 22 | CmtLength+=(GetByte()<<8); |
| 23 | } |
| 24 | else |
| 25 | #endif |
| 26 | { |
| 27 | if (MainHead.CommentInHeader) |
| 28 | { |
| 29 | // Old style (RAR 2.9) archive comment embedded into the main |
| 30 | // archive header. |
| 31 | Seek(SFXSize+SIZEOF_MARKHEAD3+SIZEOF_MAINHEAD3,SEEK_SET); |
| 32 | if (!ReadHeader() || GetHeaderType()!=HEAD3_CMT) |
| 33 | return false; |
| 34 | } |
| 35 | else |
| 36 | { |
| 37 | // Current (RAR 3.0+) version of archive comment. |
| 38 | Seek(GetStartPos(),SEEK_SET); |
| 39 | return SearchSubBlock(SUBHEAD_TYPE_CMT)!=0 && ReadCommentData(CmtData); |
| 40 | } |
| 41 | #ifndef SFX_MODULE |
| 42 | // Old style (RAR 2.9) comment header embedded into the main |
| 43 | // archive header. |
| 44 | if (BrokenHeader || CommHead.HeadSize<SIZEOF_COMMHEAD) |
| 45 | { |
| 46 | uiMsg(UIERROR_CMTBROKEN,FileName); |
| 47 | return false; |
| 48 | } |
| 49 | CmtLength=CommHead.HeadSize-SIZEOF_COMMHEAD; |
| 50 | #endif |
| 51 | } |
| 52 | #ifndef SFX_MODULE |
| 53 | if (Format==RARFMT14 && MainHead.PackComment || Format!=RARFMT14 && CommHead.Method!=0x30) |
| 54 | { |
| 55 | if (Format!=RARFMT14 && (CommHead.UnpVer < 15 || CommHead.UnpVer > VER_UNPACK || CommHead.Method > 0x35)) |
| 56 | return false; |
| 57 | ComprDataIO DataIO; |
| 58 | DataIO.SetTestMode(true); |
| 59 | uint UnpCmtLength; |
| 60 | if (Format==RARFMT14) |
| 61 | { |
| 62 | #ifdef RAR_NOCRYPT |
| 63 | return false; |
| 64 | #else |
| 65 | UnpCmtLength=GetByte(); |
| 66 | UnpCmtLength+=(GetByte()<<8); |
| 67 | if (CmtLength<2) |
| 68 | return false; |
| 69 | CmtLength-=2; |
| 70 | DataIO.SetCmt13Encryption(); |
| 71 | CommHead.UnpVer=15; |
nothing calls this directly
no test coverage detected