aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2009-01-20 10:35:15 +0200
committerLasse Collin <lasse.collin@tukaani.org>2009-01-20 10:35:15 +0200
commit0c09810cb3635cb575cb54e694d41523e7d0a335 (patch)
tree57b47dd3f1509bdf9062bd7b19042a4deb58bf10
parentFix handling of non-fatal errors in lzma_code(). (diff)
downloadxz-0c09810cb3635cb575cb54e694d41523e7d0a335.tar.xz
Use LZMA_PROG_ERROR in lzma_code() as documented in base.h.
Diffstat (limited to '')
-rw-r--r--src/liblzma/common/common.c24
1 files changed, 8 insertions, 16 deletions
diff --git a/src/liblzma/common/common.c b/src/liblzma/common/common.c
index dc43fadd..92308fe4 100644
--- a/src/liblzma/common/common.c
+++ b/src/liblzma/common/common.c
@@ -192,34 +192,26 @@ lzma_code(lzma_stream *strm, lzma_action action)
break;
case ISEQ_SYNC_FLUSH:
- if (action != LZMA_SYNC_FLUSH)
+ // The same action must be used until we return
+ // LZMA_STREAM_END, and the amount of input must not change.
+ if (action != LZMA_SYNC_FLUSH
+ || strm->internal->avail_in != strm->avail_in)
return LZMA_PROG_ERROR;
- // Check that application doesn't change avail_in once
- // LZMA_SYNC_FLUSH has been used.
- if (strm->internal->avail_in != strm->avail_in)
- return LZMA_DATA_ERROR;
-
break;
case ISEQ_FULL_FLUSH:
- if (action != LZMA_FULL_FLUSH)
+ if (action != LZMA_FULL_FLUSH
+ || strm->internal->avail_in != strm->avail_in)
return LZMA_PROG_ERROR;
- // Check that application doesn't change avail_in once
- // LZMA_FULL_FLUSH has been used.
- if (strm->internal->avail_in != strm->avail_in)
- return LZMA_DATA_ERROR;
-
break;
case ISEQ_FINISH:
- if (action != LZMA_FINISH)
+ if (action != LZMA_FINISH
+ || strm->internal->avail_in != strm->avail_in)
return LZMA_PROG_ERROR;
- if (strm->internal->avail_in != strm->avail_in)
- return LZMA_DATA_ERROR;
-
break;
case ISEQ_END: