Changeset f76d9371047ae30743021167aed4133fc0b7926a

Show
Ignore:
Timestamp:
02/17/11 20:55:06 (3 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
  • src/noit_http.c

    r123ac74 rf76d937  
    11431143  } 
    11441144  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; 
    11461146 
    11471147  return Z_OK; 
     
    11571157    uLongf olen; 
    11581158    int err; 
    1159     olen = out->allocd - out->start; 
     1159    olen = out->allocd - out->start - 2; /* leave 2 for the \r\n */ 
    11601160    err = memgzip2(res, (Bytef *)(out->buff + out->start), &olen, 
    11611161                   (Bytef *)(inbuff), (uLong)inlen, 
    11621162                   9, final ? Z_FINISH : Z_NO_FLUSH, done); 
     1163noitL(noit_error, " GZIP %d -> %d\n", inlen, olen); 
    11631164    if(Z_OK != err) { 
    11641165      noitL(noit_error, "zlib compress2 error %d\n", err); 
     
    11691170  else if(opts & NOIT_HTTP_DEFLATE) { 
    11701171    uLongf olen; 
    1171     olen = out->allocd - out->start; 
     1172    olen = out->allocd - out->start - 2; /* leave 2 for the \r\n */ 
    11721173    if(Z_OK != compress2((Bytef *)(out->buff + out->start), &olen, 
    11731174                         (Bytef *)(inbuff), (uLong)inlen, 
     
    11791180  } 
    11801181  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; 
    11821184    memcpy(out->buff + out->start, inbuff, inlen); 
    11831185    out->size += inlen;