zlib/deflate decompression, bugfix (#5723)

zlib, bugfix
This commit is contained in:
Lars Hvam 2022-08-18 06:00:46 +02:00 committed by GitHub
parent 900e3f2484
commit 7ac80cebf3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 19 additions and 11 deletions

View File

@ -153,7 +153,6 @@ CLASS ZCL_ABAPGIT_ZLIB IMPLEMENTATION.
CASE lv_btype. CASE lv_btype.
WHEN '00'. WHEN '00'.
not_compressed( ). not_compressed( ).
EXIT.
WHEN '01'. WHEN '01'.
fixed( ). fixed( ).
decode_loop( ). decode_loop( ).
@ -446,13 +445,16 @@ CLASS ZCL_ABAPGIT_ZLIB IMPLEMENTATION.
DATA: lv_len TYPE i, DATA: lv_len TYPE i,
lv_nlen TYPE i ##NEEDED. lv_nlen TYPE i ##NEEDED.
DATA lv_bytes TYPE xstring.
go_stream->take_bits( 5 ). * skip any remaining bits in current partially processed byte
go_stream->clear_bits( ).
lv_len = go_stream->take_int( 16 ). lv_len = go_stream->take_int( 16 ).
lv_nlen = go_stream->take_int( 16 ). lv_nlen = go_stream->take_int( 16 ).
gv_out = go_stream->take_bytes( lv_len ). lv_bytes = go_stream->take_bytes( lv_len ).
CONCATENATE gv_out lv_bytes INTO gv_out IN BYTE MODE.
ENDMETHOD. ENDMETHOD.

View File

@ -23,23 +23,29 @@ CLASS zcl_abapgit_zlib_stream DEFINITION
"! Take bytes, there's an implicit realignment to start at the beginning of a byte "! Take bytes, there's an implicit realignment to start at the beginning of a byte
"! i.e. if next bit of current byte is not the first bit, then this byte is skipped "! i.e. if next bit of current byte is not the first bit, then this byte is skipped
"! and the bytes are taken from the next one. "! and the bytes are taken from the next one.
"! @parameter iv_length | <p class="shorttext synchronized" lang="en">Number of BYTES to read (not bits)</p> "! @parameter iv_length | <p class="shorttext synchronized" lang="en"></p>
"! @parameter rv_bytes | <p class="shorttext synchronized" lang="en">Bytes taken</p> "! @parameter rv_bytes | <p class="shorttext synchronized" lang="en"></p>
METHODS take_bytes METHODS take_bytes
IMPORTING IMPORTING
iv_length TYPE i !iv_length TYPE i
RETURNING RETURNING
VALUE(rv_bytes) TYPE xstring. VALUE(rv_bytes) TYPE xstring .
METHODS clear_bits .
PROTECTED SECTION. PROTECTED SECTION.
PRIVATE SECTION. PRIVATE SECTION.
DATA: mv_compressed TYPE xstring,
mv_bits TYPE string.
DATA mv_bits TYPE string .
DATA mv_compressed TYPE xstring .
ENDCLASS. ENDCLASS.
CLASS zcl_abapgit_zlib_stream IMPLEMENTATION. CLASS ZCL_ABAPGIT_ZLIB_STREAM IMPLEMENTATION.
METHOD clear_bits.
CLEAR mv_bits.
ENDMETHOD.
METHOD constructor. METHOD constructor.

View File

@ -4,7 +4,7 @@ CLASS ltcl_test DEFINITION FOR TESTING
RISK LEVEL HARMLESS FINAL. RISK LEVEL HARMLESS FINAL.
PRIVATE SECTION. PRIVATE SECTION.
METHODS: test FOR TESTING. METHODS test FOR TESTING.
ENDCLASS. ENDCLASS.