| 489 | |
| 490 | |
| 491 | bool Unpack::UnpReadBuf30() |
| 492 | { |
| 493 | int DataSize=ReadTop-Inp.InAddr; // Data left to process. |
| 494 | if (DataSize<0) |
| 495 | return false; |
| 496 | if (Inp.InAddr>BitInput::MAX_SIZE/2) |
| 497 | { |
| 498 | // If we already processed more than half of buffer, let's move |
| 499 | // remaining data into beginning to free more space for new data |
| 500 | // and ensure that calling function does not cross the buffer border |
| 501 | // even if we did not read anything here. Also it ensures that read size |
| 502 | // is not less than CRYPT_BLOCK_SIZE, so we can align it without risk |
| 503 | // to make it zero. |
| 504 | if (DataSize>0) |
| 505 | memmove(Inp.InBuf,Inp.InBuf+Inp.InAddr,DataSize); |
| 506 | Inp.InAddr=0; |
| 507 | ReadTop=DataSize; |
| 508 | } |
| 509 | else |
| 510 | DataSize=ReadTop; |
| 511 | int ReadCode=UnpIO->UnpRead(Inp.InBuf+DataSize,BitInput::MAX_SIZE-DataSize); |
| 512 | if (ReadCode>0) |
| 513 | ReadTop+=ReadCode; |
| 514 | ReadBorder=ReadTop-30; |
| 515 | return ReadCode!=-1; |
| 516 | } |
| 517 | |
| 518 | |
| 519 | void Unpack::UnpWriteBuf30() |