mirror of
https://github.com/intel/isa-l.git
synced 2024-12-12 09:23:50 +01:00
igzip: Use full 32 bits histogram elements in igizp_icf_body/finish
This fix prevents possible histogram overflow in compression. Change-Id: Ie5f25d1bace7f443f432678fcfbd9050ac65113f Signed-off-by: Roy Oursler <roy.j.oursler@intel.com>
This commit is contained in:
parent
8965584ae3
commit
5d413c8b12
@ -283,7 +283,7 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
||||
test len %+ d, 0xFFFFFFFF
|
||||
jz .len_dist_huffman_pre
|
||||
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*lit_code]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*lit_code]
|
||||
movzx lit_code2, curr_data %+ b
|
||||
;; Check for len/dist match for second literal
|
||||
test len2 %+ d, 0xFFFFFFFF
|
||||
@ -333,14 +333,14 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
||||
add dist_code2, 254
|
||||
add dist_code2, len2
|
||||
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*(len2 + 254)]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*(len2 + 254)]
|
||||
|
||||
movnti dword [m_out_buf + 4], dist_code2 %+ d
|
||||
add m_out_buf, 8
|
||||
|
||||
shr dist_code2, DIST_OFFSET
|
||||
and dist_code2, 0x1F
|
||||
inc word [dist_hist + HIST_ELEM_SIZE*dist_code2]
|
||||
inc dword [dist_hist + HIST_ELEM_SIZE*dist_code2]
|
||||
|
||||
; hash = compute_hash(state->file_start + f_i) & HASH_MASK;
|
||||
and hash %+ d, HASH_MASK
|
||||
@ -385,14 +385,14 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
||||
shr curr_data2, 8
|
||||
compute_hash hash2, curr_data2
|
||||
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*len_code]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*len_code]
|
||||
|
||||
movnti dword [m_out_buf], dist_code %+ d
|
||||
add m_out_buf, 4
|
||||
|
||||
shr dist_code, DIST_OFFSET
|
||||
and dist_code, 0x1F
|
||||
inc word [dist_hist + HIST_ELEM_SIZE*dist_code]
|
||||
inc dword [dist_hist + HIST_ELEM_SIZE*dist_code]
|
||||
|
||||
; hash = compute_hash(state->file_start + f_i) & HASH_MASK;
|
||||
and hash %+ d, HASH_MASK
|
||||
@ -408,7 +408,7 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
||||
add f_i, 1
|
||||
MOVQ curr_data, xdata
|
||||
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*lit_code2]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*lit_code2]
|
||||
|
||||
shl lit_code2, DIST_OFFSET
|
||||
lea lit_code, [lit_code + lit_code2 + (31 << DIST_OFFSET)]
|
||||
@ -497,7 +497,7 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
||||
%endif
|
||||
movzx lit_code, curr_data %+ b
|
||||
shr curr_data, 8
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*lit_code]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*lit_code]
|
||||
jmp .len_dist_lit_huffman
|
||||
|
||||
.write_first_byte:
|
||||
@ -513,7 +513,7 @@ isal_deflate_icf_body_ %+ METHOD %+ _ %+ ARCH %+ :
|
||||
compute_hash hash2, tmp2
|
||||
|
||||
and curr_data, 0xff
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*curr_data]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*curr_data]
|
||||
or curr_data, LIT
|
||||
|
||||
movnti dword [m_out_buf], curr_data %+ d
|
||||
|
@ -206,7 +206,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
||||
lea code, [len + 254]
|
||||
|
||||
or code2, code
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*code]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*code]
|
||||
|
||||
; for (k = f_i+1, f_i += len-1; k <= f_i; k++) {
|
||||
lea tmp3, [f_i + 1] ; tmp3 <= k
|
||||
@ -236,7 +236,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
||||
write_dword code2, m_out_buf
|
||||
shr code2, DIST_OFFSET
|
||||
and code2, 0x1F
|
||||
inc word [dist_hist + HIST_ELEM_SIZE*code2]
|
||||
inc dword [dist_hist + HIST_ELEM_SIZE*code2]
|
||||
; continue
|
||||
cmp f_i, [rsp + f_end_i_mem_offset]
|
||||
jl .loop2
|
||||
@ -245,7 +245,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
||||
.encode_literal:
|
||||
; get_lit_code(state->file_start[f_i], &code2, &code_len2);
|
||||
movzx tmp5, byte [file_start + f_i]
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*tmp5]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*tmp5]
|
||||
or tmp5, LIT
|
||||
write_dword tmp5, m_out_buf
|
||||
; continue
|
||||
@ -267,7 +267,7 @@ isal_deflate_icf_finish_ %+ METHOD %+ _01:
|
||||
ja .out_end
|
||||
|
||||
movzx tmp5, byte [file_start + f_i]
|
||||
inc word [lit_len_hist + HIST_ELEM_SIZE*tmp5]
|
||||
inc dword [lit_len_hist + HIST_ELEM_SIZE*tmp5]
|
||||
or tmp5, LIT
|
||||
write_dword tmp5, m_out_buf
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user