summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPatrick McDermott <patrick.mcdermott@libiquity.com>2023-04-13 08:15:22 (EDT)
committer Patrick McDermott <patrick.mcdermott@libiquity.com>2023-04-13 08:15:22 (EDT)
commit9a8179ef438ed57ad9e1fb34844eb4f9dae6b138 (patch)
treedb7071008fd3a97ec3e8bc5ee026477dabb9ae6a
parent91fb62782e7db0b3f1f296e8132871b363440a18 (diff)
ustar: Fix EOF logic
-rw-r--r--src/gzip.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/gzip.c b/src/gzip.c
index 472d656..f3fbdb9 100644
--- a/src/gzip.c
+++ b/src/gzip.c
@@ -65,13 +65,13 @@ static int
_opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state)
{
for (;;) {
- if (feof(state->input_file)) {
- fclose(state->input_file);
- state->input_file = NULL;
- inflateEnd(&state->stream);
- return OPKG_OPK_OK;
- }
if (state->stream.avail_in == 0) {
+ if (feof(state->input_file)) {
+ fclose(state->input_file);
+ state->input_file = NULL;
+ inflateEnd(&state->stream);
+ return OPKG_OPK_ERROR;
+ }
state->stream.avail_in = fread(state->input_buffer,
1, OPKG_OPK_GZIP_BUFFER_SIZE,
state->input_file);
@@ -88,9 +88,13 @@ _opkg_opk_gzip_next_record_from_file(struct opkg_opk_gzip_state *state)
}
switch (inflate(&state->stream, Z_SYNC_FLUSH)) {
case Z_OK:
- case Z_STREAM_END:
case Z_BUF_ERROR:
break;
+ case Z_STREAM_END:
+ fclose(state->input_file);
+ state->input_file = NULL;
+ inflateEnd(&state->stream);
+ return OPKG_OPK_END;
default:
fclose(state->input_file);
state->input_file = NULL;