Author: rhuijben Date: Mon Oct 26 19:16:28 2015 New Revision: 1710681 URL: http://svn.apache.org/viewvc?rev=1710681&view=rev Log: Fix two cases in the http2 framing buckets where a short read would make us parse invalid data.
* buckets/http2_frame_buckets.c (serf_bucket_http2_unframe_read_info, serf_http2_unpad_read_padsize): Return APR_EAGAIN on a short read with success status. Modified: serf/trunk/buckets/http2_frame_buckets.c Modified: serf/trunk/buckets/http2_frame_buckets.c URL: http://svn.apache.org/viewvc/serf/trunk/buckets/http2_frame_buckets.c?rev=1710681&r1=1710680&r2=1710681&view=diff ============================================================================== --- serf/trunk/buckets/http2_frame_buckets.c (original) +++ serf/trunk/buckets/http2_frame_buckets.c Mon Oct 26 19:16:28 2015 @@ -122,6 +122,9 @@ serf_bucket_http2_unframe_read_info(serf if (ctx->max_payload_size < payload_length) return SERF_ERROR_HTTP2_FRAME_SIZE_ERROR; } + else if (!status) + status = APR_EAGAIN; + } return status; } @@ -315,9 +318,10 @@ serf_http2_unpad_read_padsize(serf_bucke return APR_SUCCESS; status = serf_bucket_read(ctx->stream, 1, &data, &len); - if (! SERF_BUCKET_READ_ERROR(status)) + if (! SERF_BUCKET_READ_ERROR(status) && len > 0) { apr_int64_t remaining; + ctx->pad_length = *(unsigned char *)data; ctx->pad_remaining = ctx->pad_length; ctx->padsize_read = TRUE; @@ -342,6 +346,9 @@ serf_http2_unpad_read_padsize(serf_bucke ctx->payload_remaining = (apr_size_t)remaining - ctx->pad_length; } + else if (!status) + status = APR_EAGAIN; + return status; }