Commit 92088384cf9225cf40ca024b6ec669222b785347

Stefan Sperling 2018-04-01T23:00:57

fix use of unitialized value in case of EOF in got_inflate_read()

diff --git a/lib/zbuf.c b/lib/zbuf.c
index 93279f0..2b3120f 100644
--- a/lib/zbuf.c
+++ b/lib/zbuf.c
@@ -71,7 +71,7 @@ got_inflate_read(struct got_zstream_buf *zb, FILE *f, size_t *outlenp)
 {
 	size_t last_total_out = zb->z.total_out;
 	z_stream *z = &zb->z;
-	int ret;
+	int ret = Z_ERRNO;
 
 	z->next_out = zb->outbuf;
 	z->avail_out = zb->outlen;
@@ -83,7 +83,9 @@ got_inflate_read(struct got_zstream_buf *zb, FILE *f, size_t *outlenp)
 			if (n == 0) {
 				if (ferror(f))
 					return got_ferror(f, GOT_ERR_IO);
-				break; /* EOF */
+				/* EOF */
+				ret = Z_STREAM_END;
+				break;
 			}
 			z->next_in = zb->inbuf;
 			z->avail_in = n;