summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Hiesey <john@hiesey.com>2015-10-07 13:30:33 -0700
committerColin Walters <walters@verbum.org>2015-10-10 10:27:17 -0400
commitdd35e1b9cdb4b8abf0ffd15263ae33db3e729d75 (patch)
tree0a629e160cbf25f7748c5e0ea9df3a7cef65b9fb
parentb6e2eaf212bac6231dcaf03491b251b0a0850002 (diff)
downloadostree-dd35e1b9cdb4b8abf0ffd15263ae33db3e729d75.tar.gz
static-delta: Handle LZMA_BUF_ERROR returned by zlib
zlib can return LZMA_BUF_ERROR, which indicates that either the input or output buffer has size zero. This case should cause the correct error to be passed back from g_converter_convert to expand the relevant buffer. Since this error is ambiguous as to which buffer is too small, an explicit check on the output buffer size is added as well. https://bugzilla.gnome.org/show_bug.cgi?id=756260
-rw-r--r--src/libostree/ostree-lzma-common.c4
-rw-r--r--src/libostree/ostree-lzma-compressor.c7
-rw-r--r--src/libostree/ostree-lzma-decompressor.c7
3 files changed, 18 insertions, 0 deletions
diff --git a/src/libostree/ostree-lzma-common.c b/src/libostree/ostree-lzma-common.c
index 3600efd3..61f3a2a4 100644
--- a/src/libostree/ostree-lzma-common.c
+++ b/src/libostree/ostree-lzma-common.c
@@ -62,6 +62,10 @@ _ostree_lzma_return (lzma_ret res,
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Data is corrupt");
return G_CONVERTER_ERROR;
+ case LZMA_BUF_ERROR:
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_PARTIAL_INPUT,
+ "Input buffer too small");
+ return G_CONVERTER_ERROR;
default:
g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_FAILED,
"Unrecognized LZMA error");
diff --git a/src/libostree/ostree-lzma-compressor.c b/src/libostree/ostree-lzma-compressor.c
index ce429f99..1ec03c41 100644
--- a/src/libostree/ostree-lzma-compressor.c
+++ b/src/libostree/ostree-lzma-compressor.c
@@ -173,6 +173,13 @@ _ostree_lzma_compressor_convert (GConverter *converter,
int res;
lzma_action action;
+ if (inbuf_size != 0 && outbuf_size == 0)
+ {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NO_SPACE,
+ "Output buffer too small");
+ return G_CONVERTER_ERROR;
+ }
+
if (!self->initialized)
{
res = lzma_easy_encoder (&self->lstream, 8, LZMA_CHECK_CRC64);
diff --git a/src/libostree/ostree-lzma-decompressor.c b/src/libostree/ostree-lzma-decompressor.c
index 51630132..b46e8fb2 100644
--- a/src/libostree/ostree-lzma-decompressor.c
+++ b/src/libostree/ostree-lzma-decompressor.c
@@ -104,6 +104,13 @@ _ostree_lzma_decompressor_convert (GConverter *converter,
OstreeLzmaDecompressor *self = OSTREE_LZMA_DECOMPRESSOR (converter);
int res;
+ if (inbuf_size != 0 && outbuf_size == 0)
+ {
+ g_set_error_literal (error, G_IO_ERROR, G_IO_ERROR_NO_SPACE,
+ "Output buffer too small");
+ return G_CONVERTER_ERROR;
+ }
+
if (!self->initialized)
{
res = lzma_stream_decoder (&self->lstream, G_MAXUINT64, 0);