mirror of
https://xff.cz/git/u-boot/
synced 2025-09-29 22:41:17 +02:00
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: Simon Glass <sjg@chromium.org>
This commit is contained in:
@@ -73,6 +73,7 @@ int zunzip(void *dst, int dstlen, unsigned char *src, unsigned long *lenp,
|
|||||||
int stoponerr, int offset)
|
int stoponerr, int offset)
|
||||||
{
|
{
|
||||||
z_stream s;
|
z_stream s;
|
||||||
|
int err = 0;
|
||||||
int r;
|
int r;
|
||||||
|
|
||||||
s.zalloc = gzalloc;
|
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 &&
|
if (stoponerr == 1 && r != Z_STREAM_END &&
|
||||||
(s.avail_out == 0 || r != Z_BUF_ERROR)) {
|
(s.avail_out == 0 || r != Z_BUF_ERROR)) {
|
||||||
printf("Error: inflate() returned %d\n", r);
|
printf("Error: inflate() returned %d\n", r);
|
||||||
inflateEnd(&s);
|
err = -1;
|
||||||
return -1;
|
break;
|
||||||
}
|
}
|
||||||
s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
|
s.avail_in = *lenp - offset - (int)(s.next_out - (unsigned char*)dst);
|
||||||
} while (r == Z_BUF_ERROR);
|
} while (r == Z_BUF_ERROR);
|
||||||
*lenp = s.next_out - (unsigned char *) dst;
|
*lenp = s.next_out - (unsigned char *) dst;
|
||||||
inflateEnd(&s);
|
inflateEnd(&s);
|
||||||
|
|
||||||
return 0;
|
return err;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user