summaryrefslogtreecommitdiff
path: root/gzread.c
diff options
context:
space:
mode:
Diffstat (limited to 'gzread.c')
-rw-r--r--gzread.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/gzread.c b/gzread.c
index 3811157..deea79b 100644
--- a/gzread.c
+++ b/gzread.c
@@ -24,11 +24,15 @@ local int gz_load(state, buf, len, have)
unsigned len;
unsigned *have;
{
- z_ssize_t ret;
+ int ret;
+ unsigned get, max = ((unsigned)-1 >> 2) + 1;
*have = 0;
do {
- ret = read(state->fd, buf + *have, len - *have);
+ get = len - *have;
+ if (get > max)
+ get = max;
+ ret = read(state->fd, buf + *have, get);
if (ret <= 0)
break;
*have += (unsigned)ret;