提交 9c55c54f 编写于 作者: S Simon Glass 提交者: Tom Rini

gunzip: Update lenp even on error

This allows the caller to easily detect how much of the destination buffer
has been used.
Signed-off-by: NSimon Glass <sjg@chromium.org>
上级 362a0e43
......@@ -73,6 +73,7 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
int stoponerr, int offset)
{
z_stream s;
int err = 0;
int r;
s.zalloc = gzalloc;
......@@ -92,13 +93,13 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
if (stoponerr == 1 && r != Z_STREAM_END &&
(s.avail_out == 0 || r != Z_BUF_ERROR)) {
printf("Error: inflate() returned %d\n", r);
inflateEnd(&s);
return -1;
err = -1;
break;
}
s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
} while (r == Z_BUF_ERROR);
*lenp = s.next_out - (unsigned char *) dst;
inflateEnd(&s);
return 0;
return err;
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册