~ubuntu-branches/ubuntu/trusty/serf/trusty-security

« back to all changes in this revision

Viewing changes to buckets/deflate_buckets.c

  • Committer: Bazaar Package Importer
  • Author(s): Peter Samuelson
  • Date: 2011-06-27 18:09:28 UTC
  • mfrom: (1.2.5 upstream)
  • mto: (3.3.1 sid)
  • mto: This revision was merged to the branch mainline in revision 11.
  • Revision ID: james.westby@ubuntu.com-20110627180928-ybwzd3hmx82nu3ir
Tags: 1.0.0~0+svn1514-1
* New upstream snapshot.
  - patches/abi-0.x: Remove as obsolete.
  - patches/kqueue: Forward-port.
  - Bump ABI: libserf0.7{,-dbg} -> libserf1{,-dbg}
  - patches/ip6-localhost: New patch: temporary (I hope) workaround for
    IPv4 / IPv6 confusion in testsuite.
* Implement Multi-Arch: same.
* libserf-dev Conflicts: libserf-0-0-dev, not Breaks.  Thanks, lintian.

Show diffs side-by-side

added added

removed removed

Lines of Context:
60
60
    int bufferSize;
61
61
 
62
62
    /* How much of the chunk, or the terminator, do we have left to read? */
63
 
    apr_int64_t stream_left;
 
63
    apr_size_t stream_left;
64
64
 
65
65
    /* How much are we supposed to read? */
66
 
    apr_int64_t stream_size;
 
66
    apr_size_t stream_size;
67
67
 
68
68
    int stream_status; /* What was the last status we read? */
69
69
 
178
178
        case STATE_HEADER:
179
179
            if (ctx->hdr_buffer[0] != deflate_magic[0] ||
180
180
                ctx->hdr_buffer[1] != deflate_magic[1]) {
181
 
                return APR_EGENERAL;
 
181
                return SERF_ERROR_DECOMPRESSION_FAILED;
182
182
            }
183
183
            if (ctx->hdr_buffer[3] != 0) {
184
 
                return APR_EGENERAL;
 
184
                return SERF_ERROR_DECOMPRESSION_FAILED;
185
185
            }
186
186
            ctx->state++;
187
187
            break;
189
189
            /* Do the checksum computation. */
190
190
            compCRC = getLong((unsigned char*)ctx->hdr_buffer);
191
191
            if (ctx->crc != compCRC) {
192
 
                return APR_EGENERAL;
 
192
                return SERF_ERROR_DECOMPRESSION_FAILED;
193
193
            }
194
194
            compLen = getLong((unsigned char*)ctx->hdr_buffer + 4);
195
195
            if (ctx->zstream.total_out != compLen) {
196
 
                return APR_EGENERAL;
 
196
                return SERF_ERROR_DECOMPRESSION_FAILED;
197
197
            }
198
198
            ctx->state++;
199
199
            break;
200
200
        case STATE_INIT:
201
201
            zRC = inflateInit2(&ctx->zstream, ctx->windowSize);
202
202
            if (zRC != Z_OK) {
203
 
                return APR_EGENERAL;
 
203
                return SERF_ERROR_DECOMPRESSION_FAILED;
204
204
            }
205
205
            ctx->zstream.next_out = ctx->buffer;
206
206
            ctx->zstream.avail_out = ctx->bufferSize;
331
331
                    break;
332
332
                }
333
333
                if (zRC != Z_OK) {
334
 
                    return APR_EGENERAL;
 
334
                    return SERF_ERROR_DECOMPRESSION_FAILED;
335
335
                }
336
336
            }
337
337
            /* Okay, we've inflated.  Try to read. */
344
344
                 * we'll iterate one more time.
345
345
                 */
346
346
                if (APR_STATUS_IS_EOF(status)) {
347
 
                    return APR_SUCCESS;
 
347
                    /* No more data to read from the stream, and everything
 
348
                       inflated. If all data was received correctly, state
 
349
                       should have been advanced to STATE_READING_VERIFY or
 
350
                       STATE_FINISH. If not, then the data was incomplete
 
351
                       and we have an error. */
 
352
                    if (ctx->state != STATE_INFLATE)
 
353
                        return APR_SUCCESS;
 
354
                    else
 
355
                        return SERF_ERROR_DECOMPRESSION_FAILED;
348
356
                }
349
357
            }
350
358
            return status;
373
381
    serf_default_read_bucket,
374
382
    serf_deflate_peek,
375
383
    serf_deflate_destroy_and_data,
376
 
    serf_default_snapshot,
377
 
    serf_default_restore_snapshot,
378
 
    serf_default_is_snapshot_set,
379
384
};
380