| 230 | |
| 231 | |
| 232 | bool CmdExtract::ExtractCurrentFile(Archive &Arc,size_t HeaderSize,bool &Repeat) |
| 233 | { |
| 234 | wchar Command=Cmd->Command[0]; |
| 235 | if (HeaderSize==0) |
| 236 | if (DataIO.UnpVolume) |
| 237 | { |
| 238 | #ifdef NOVOLUME |
| 239 | return false; |
| 240 | #else |
| 241 | // Supposing we unpack an old RAR volume without the end of archive |
| 242 | // record and last file is not split between volumes. |
| 243 | if (!MergeArchive(Arc,&DataIO,false,Command)) |
| 244 | { |
| 245 | ErrHandler.SetErrorCode(RARX_WARNING); |
| 246 | return false; |
| 247 | } |
| 248 | #endif |
| 249 | } |
| 250 | else |
| 251 | return false; |
| 252 | |
| 253 | HEADER_TYPE HeaderType=Arc.GetHeaderType(); |
| 254 | if (HeaderType!=HEAD_FILE) |
| 255 | { |
| 256 | #ifndef SFX_MODULE |
| 257 | if (Arc.Format==RARFMT15 && HeaderType==HEAD3_OLDSERVICE && PrevProcessed) |
| 258 | SetExtraInfo20(Cmd,Arc,DestFileName); |
| 259 | #endif |
| 260 | if (HeaderType==HEAD_SERVICE && PrevProcessed) |
| 261 | SetExtraInfo(Cmd,Arc,DestFileName); |
| 262 | if (HeaderType==HEAD_ENDARC) |
| 263 | if (Arc.EndArcHead.NextVolume) |
| 264 | { |
| 265 | #ifdef NOVOLUME |
| 266 | return false; |
| 267 | #else |
| 268 | if (!MergeArchive(Arc,&DataIO,false,Command)) |
| 269 | { |
| 270 | ErrHandler.SetErrorCode(RARX_WARNING); |
| 271 | return false; |
| 272 | } |
| 273 | Arc.Seek(Arc.CurBlockPos,SEEK_SET); |
| 274 | return true; |
| 275 | #endif |
| 276 | } |
| 277 | else |
| 278 | return false; |
| 279 | Arc.SeekToNext(); |
| 280 | return true; |
| 281 | } |
| 282 | PrevProcessed=false; |
| 283 | |
| 284 | // We can get negative sizes in corrupt archive and it is unacceptable |
| 285 | // for size comparisons in ComprDataIO::UnpRead, where we cast sizes |
| 286 | // to size_t and can exceed another read or available size. We could fix it |
| 287 | // when reading an archive. But we prefer to do it here, because this |
| 288 | // function is called directly in unrar.dll, so we fix bad parameters |
| 289 | // passed to dll. Also we want to see real negative sizes in the listing |
no test coverage detected