Browse Source

[zbin] Fix check for existence of most recent output byte

The code in lzma_literal() checks to see if we are at the start of the
compressed input data in order to determine whether or not a most
recent output byte exists.  This check is incorrect, since
initialisation of the decompressor will always consume the first five
bytes of the compressed input data.

Fix by instead checking whether or not we are at the start of the
output data stream.  This is, in any case, a more logical check.

This issue was masked during development and testing since virtual
machines tend to zero the initial contents of RAM; the spuriously-read
"most recent output byte" is therefore likely to already be a zero
when running in a virtual machine.

Reported-by: Robin Smidsrød <robin@smidsrod.no>
Signed-off-by: Michael Brown <mcb30@ipxe.org>
tags/v1.20.1
Michael Brown 9 years ago
parent
commit
ea3be0f4a6
1 changed files with 1 additions and 3 deletions
  1. 1
    3
      src/arch/i386/prefix/unlzma.S

+ 1
- 3
src/arch/i386/prefix/unlzma.S View File

194
 
194
 
195
 	.struct	0
195
 	.struct	0
196
 lzma_dec:
196
 lzma_dec:
197
-in_start:	.long	0
198
 out_start:	.long	0
197
 out_start:	.long	0
199
 rc_code:	.long	0
198
 rc_code:	.long	0
200
 rc_range:	.long	0
199
 rc_range:	.long	0
487
 lzma_literal:
486
 lzma_literal:
488
 	/* Get most recent output byte, if available */
487
 	/* Get most recent output byte, if available */
489
 	xorl	%ebx, %ebx
488
 	xorl	%ebx, %ebx
490
-	cmpl	%esi, in_start(%ebp)
489
+	cmpl	%edi, out_start(%ebp)
491
 	je	1f
490
 	je	1f
492
 	movb	%es:-1(%edi), %bh
491
 	movb	%es:-1(%edi), %bh
493
 1:	/* Locate probability estimate set */
492
 1:	/* Locate probability estimate set */
901
 	popw	%es
900
 	popw	%es
902
 	popl	%edi
901
 	popl	%edi
903
 	/* Initialise remaining parameters */
902
 	/* Initialise remaining parameters */
904
-	movl	%esi, in_start(%ebp)
905
 	movl	%edi, out_start(%ebp)
903
 	movl	%edi, out_start(%ebp)
906
 	print_character $('\n')
904
 	print_character $('\n')
907
 	ADDR32 lodsb	/* discard initial byte */
905
 	ADDR32 lodsb	/* discard initial byte */

Loading…
Cancel
Save