public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] XZ decompressor: Fix decoding of empty LZMA2 streams
@ 2011-05-01 16:38 Lasse Collin
  2011-05-03 21:36 ` Andrew Morton
  0 siblings, 1 reply; 4+ messages in thread
From: Lasse Collin @ 2011-05-01 16:38 UTC (permalink / raw)
  To: Linus Torvalds; +Cc: Andrew Morton, linux-kernel

From: Lasse Collin <lasse.collin@tukaani.org>

The old code considered valid empty LZMA2 streams to be corrupt.
Note that a typical empty .xz file has no LZMA2 data at all,
and thus most .xz files having no uncompressed data are handled
correctly even without this fix.

Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
---

 lib/xz/xz_dec_lzma2.c |    6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff -uprN linux-2.6.39-rc5-git5.orig/lib/xz/xz_dec_lzma2.c linux-2.6.39-rc5-git5/lib/xz/xz_dec_lzma2.c
--- linux-2.6.39-rc5-git5.orig/lib/xz/xz_dec_lzma2.c	2011-05-01 17:56:38.000000000 +0300
+++ linux-2.6.39-rc5-git5/lib/xz/xz_dec_lzma2.c	2011-05-01 18:06:03.000000000 +0300
@@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(s
 			 */
 			tmp = b->in[b->in_pos++];
 
+			if (tmp == 0x00)
+				return XZ_STREAM_END;
+
 			if (tmp >= 0xE0 || tmp == 0x01) {
 				s->lzma2.need_props = true;
 				s->lzma2.need_dict_reset = false;
@@ -1001,9 +1004,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(s
 						lzma_reset(s);
 				}
 			} else {
-				if (tmp == 0x00)
-					return XZ_STREAM_END;
-
 				if (tmp > 0x02)
 					return XZ_DATA_ERROR;
 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] XZ decompressor: Fix decoding of empty LZMA2 streams
  2011-05-01 16:38 [PATCH] XZ decompressor: Fix decoding of empty LZMA2 streams Lasse Collin
@ 2011-05-03 21:36 ` Andrew Morton
  2011-05-03 22:22   ` Lasse Collin
  0 siblings, 1 reply; 4+ messages in thread
From: Andrew Morton @ 2011-05-03 21:36 UTC (permalink / raw)
  To: Lasse Collin; +Cc: Linus Torvalds, linux-kernel, stable

On Sun, 1 May 2011 19:38:42 +0300
Lasse Collin <lasse.collin@tukaani.org> wrote:

> From: Lasse Collin <lasse.collin@tukaani.org>
> 
> The old code considered valid empty LZMA2 streams to be corrupt.
> Note that a typical empty .xz file has no LZMA2 data at all,
> and thus most .xz files having no uncompressed data are handled
> correctly even without this fix.
> 
> Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>

The patch didn't have the cc:stable tag, but appears to be needed in
2.6.38.x and perhaps earlier, yes?

It's commit 646032e3b05b32d3f20cb108a030593d9d792eb5 in mainline.

> 
>  lib/xz/xz_dec_lzma2.c |    6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
> 
> diff -uprN linux-2.6.39-rc5-git5.orig/lib/xz/xz_dec_lzma2.c linux-2.6.39-rc5-git5/lib/xz/xz_dec_lzma2.c
> --- linux-2.6.39-rc5-git5.orig/lib/xz/xz_dec_lzma2.c	2011-05-01 17:56:38.000000000 +0300
> +++ linux-2.6.39-rc5-git5/lib/xz/xz_dec_lzma2.c	2011-05-01 18:06:03.000000000 +0300
> @@ -969,6 +969,9 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(s
>  			 */
>  			tmp = b->in[b->in_pos++];
>  
> +			if (tmp == 0x00)
> +				return XZ_STREAM_END;
> +
>  			if (tmp >= 0xE0 || tmp == 0x01) {
>  				s->lzma2.need_props = true;
>  				s->lzma2.need_dict_reset = false;
> @@ -1001,9 +1004,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_run(s
>  						lzma_reset(s);
>  				}
>  			} else {
> -				if (tmp == 0x00)
> -					return XZ_STREAM_END;
> -
>  				if (tmp > 0x02)
>  					return XZ_DATA_ERROR;
>  

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH] XZ decompressor: Fix decoding of empty LZMA2 streams
  2011-05-03 21:36 ` Andrew Morton
@ 2011-05-03 22:22   ` Lasse Collin
  2011-05-04 23:11     ` [stable] " Greg KH
  0 siblings, 1 reply; 4+ messages in thread
From: Lasse Collin @ 2011-05-03 22:22 UTC (permalink / raw)
  To: Andrew Morton; +Cc: Linus Torvalds, linux-kernel, stable

On 2011-05-04 Andrew Morton wrote:
> Lasse Collin <lasse.collin@tukaani.org> wrote:
> > From: Lasse Collin <lasse.collin@tukaani.org>
> > 
> > The old code considered valid empty LZMA2 streams to be corrupt.
> > Note that a typical empty .xz file has no LZMA2 data at all,
> > and thus most .xz files having no uncompressed data are handled
> > correctly even without this fix.
> > 
> > Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
> 
> The patch didn't have the cc:stable tag, but appears to be needed in
> 2.6.38.x and perhaps earlier, yes?
> 
> It's commit 646032e3b05b32d3f20cb108a030593d9d792eb5 in mainline.

Thanks. It's good for 2.6.38.x. Older ones don't have XZ support.

-- 
Lasse Collin  |  IRC: Larhzu @ IRCnet & Freenode

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [stable] [PATCH] XZ decompressor: Fix decoding of empty LZMA2 streams
  2011-05-03 22:22   ` Lasse Collin
@ 2011-05-04 23:11     ` Greg KH
  0 siblings, 0 replies; 4+ messages in thread
From: Greg KH @ 2011-05-04 23:11 UTC (permalink / raw)
  To: Lasse Collin; +Cc: Andrew Morton, Linus Torvalds, linux-kernel, stable

On Wed, May 04, 2011 at 01:22:36AM +0300, Lasse Collin wrote:
> On 2011-05-04 Andrew Morton wrote:
> > Lasse Collin <lasse.collin@tukaani.org> wrote:
> > > From: Lasse Collin <lasse.collin@tukaani.org>
> > > 
> > > The old code considered valid empty LZMA2 streams to be corrupt.
> > > Note that a typical empty .xz file has no LZMA2 data at all,
> > > and thus most .xz files having no uncompressed data are handled
> > > correctly even without this fix.
> > > 
> > > Signed-off-by: Lasse Collin <lasse.collin@tukaani.org>
> > 
> > The patch didn't have the cc:stable tag, but appears to be needed in
> > 2.6.38.x and perhaps earlier, yes?
> > 
> > It's commit 646032e3b05b32d3f20cb108a030593d9d792eb5 in mainline.
> 
> Thanks. It's good for 2.6.38.x. Older ones don't have XZ support.

Now queued up, thanks.

greg k-h

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2011-05-04 23:18 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-05-01 16:38 [PATCH] XZ decompressor: Fix decoding of empty LZMA2 streams Lasse Collin
2011-05-03 21:36 ` Andrew Morton
2011-05-03 22:22   ` Lasse Collin
2011-05-04 23:11     ` [stable] " Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox