| 571 | namespace |
| 572 | { |
| 573 | inline UCHAR* unpack(record_param* rpb, ULONG outLength, UCHAR* output) |
| 574 | { |
| 575 | if (rpb->rpb_flags & rpb_not_packed) |
| 576 | { |
| 577 | const auto length = MIN(rpb->rpb_length, outLength); |
| 578 | |
| 579 | memcpy(output, rpb->rpb_address, length); |
| 580 | output += length; |
| 581 | |
| 582 | if (rpb->rpb_length > length) |
| 583 | { |
| 584 | // Short records may be zero-padded up to the fragmented header size. |
| 585 | // Take it into account while checking for a possible buffer overrun. |
| 586 | |
| 587 | auto tail = rpb->rpb_address + length; |
| 588 | const auto end = rpb->rpb_address + rpb->rpb_length; |
| 589 | |
| 590 | while (tail < end) |
| 591 | { |
| 592 | if (*tail++) |
| 593 | BUGCHECK(179); // msg 179 decompression overran buffer |
| 594 | } |
| 595 | } |
| 596 | |
| 597 | return output; |
| 598 | } |
| 599 | |
| 600 | return Compressor::unpack(rpb->rpb_length, rpb->rpb_address, outLength, output); |
| 601 | } |
| 602 | }; |
| 603 | |
| 604 |
no outgoing calls
no test coverage detected