Changeset f76d9371047ae30743021167aed4133fc0b7926a
- Timestamp:
- 02/17/11 20:55:06
(2 years ago)
- Author:
- Theo Schlossnagle <jesus@omniti.com>
- git-committer:
- Theo Schlossnagle <jesus@omniti.com> 1297976106 +0000
- git-parent:
[637731dd84df22000af7615a62662e35d76413a9]
- git-author:
- Theo Schlossnagle <jesus@omniti.com> 1297976106 +0000
- Message:
We need to make sure we only encode up to 2 characters shy of the allocation
because we may need to write out \r\n.
Also, the output length was calculated wrong...
fixes #335
-
Files:
-
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
| r123ac74 |
rf76d937 |
|
| 1143 | 1143 | } |
|---|
| 1144 | 1144 | if(done) *done = (err == Z_STREAM_END) ? noit_true : noit_false; |
|---|
| 1145 | | *destLen = res->gzip->total_out + skip; |
|---|
| | 1145 | *destLen = (*destLen - res->gzip->avail_out) + skip; |
|---|
| 1146 | 1146 | |
|---|
| 1147 | 1147 | return Z_OK; |
|---|
| … | … | |
| 1157 | 1157 | uLongf olen; |
|---|
| 1158 | 1158 | int err; |
|---|
| 1159 | | olen = out->allocd - out->start; |
|---|
| | 1159 | olen = out->allocd - out->start - 2; /* leave 2 for the \r\n */ |
|---|
| 1160 | 1160 | err = memgzip2(res, (Bytef *)(out->buff + out->start), &olen, |
|---|
| 1161 | 1161 | (Bytef *)(inbuff), (uLong)inlen, |
|---|
| 1162 | 1162 | 9, final ? Z_FINISH : Z_NO_FLUSH, done); |
|---|
| | 1163 | noitL(noit_error, " GZIP %d -> %d\n", inlen, olen); |
|---|
| 1163 | 1164 | if(Z_OK != err) { |
|---|
| 1164 | 1165 | noitL(noit_error, "zlib compress2 error %d\n", err); |
|---|
| … | … | |
| 1169 | 1170 | else if(opts & NOIT_HTTP_DEFLATE) { |
|---|
| 1170 | 1171 | uLongf olen; |
|---|
| 1171 | | olen = out->allocd - out->start; |
|---|
| | 1172 | olen = out->allocd - out->start - 2; /* leave 2 for the \r\n */ |
|---|
| 1172 | 1173 | if(Z_OK != compress2((Bytef *)(out->buff + out->start), &olen, |
|---|
| 1173 | 1174 | (Bytef *)(inbuff), (uLong)inlen, |
|---|
| … | … | |
| 1179 | 1180 | } |
|---|
| 1180 | 1181 | else { |
|---|
| 1181 | | if(inlen > out->allocd - out->start) return noit_false; |
|---|
| | 1182 | /* leave 2 for the \r\n */ |
|---|
| | 1183 | if(inlen > out->allocd - out->start - 2) return noit_false; |
|---|
| 1182 | 1184 | memcpy(out->buff + out->start, inbuff, inlen); |
|---|
| 1183 | 1185 | out->size += inlen; |
|---|