comparison src/http/ngx_http_spdy_filter_module.c @ 5517:9d1479234f3c

SPDY: fixed off_t/size_t type conversions on 32 bits platforms. Parameters of ngx_http_spdy_filter_get_shadow() are changed from size_t to off_t since the last call of the function may get size and offset from the rest of a file buffer. This fixes possible data loss rightfully complained by MSVC on 32 bits systems where off_t is 8 bytes long while size_t is only 4 bytes. The other two type casts are needed just to suppress warnings about possible data loss also complained by MSVC but false positive in these cases.
author Valentin Bartenev <vbart@nginx.com>
date Wed, 15 Jan 2014 13:23:31 +0400
parents 439d05a037a3
children d5de6c25b759
comparison
equal deleted inserted replaced
5516:439d05a037a3 5517:9d1479234f3c
33 33
34 static ngx_inline ngx_int_t ngx_http_spdy_filter_send( 34 static ngx_inline ngx_int_t ngx_http_spdy_filter_send(
35 ngx_connection_t *fc, ngx_http_spdy_stream_t *stream); 35 ngx_connection_t *fc, ngx_http_spdy_stream_t *stream);
36 36
37 static ngx_chain_t *ngx_http_spdy_filter_get_shadow( 37 static ngx_chain_t *ngx_http_spdy_filter_get_shadow(
38 ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, size_t offset, 38 ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, off_t offset, off_t size);
39 size_t size);
40 static ngx_http_spdy_out_frame_t *ngx_http_spdy_filter_get_data_frame( 39 static ngx_http_spdy_out_frame_t *ngx_http_spdy_filter_get_data_frame(
41 ngx_http_spdy_stream_t *stream, size_t len, ngx_chain_t *first, 40 ngx_http_spdy_stream_t *stream, size_t len, ngx_chain_t *first,
42 ngx_chain_t *last); 41 ngx_chain_t *last);
43 42
44 static ngx_int_t ngx_http_spdy_syn_frame_handler( 43 static ngx_int_t ngx_http_spdy_syn_frame_handler(
700 } 699 }
701 700
702 *ln = cl; 701 *ln = cl;
703 ln = &cl->next; 702 ln = &cl->next;
704 703
705 rest -= size; 704 rest -= (size_t) size;
706 in = in->next; 705 in = in->next;
707 706
708 if (in == NULL) { 707 if (in == NULL) {
709 frame_size -= rest; 708 frame_size -= rest;
710 rest = 0; 709 rest = 0;
750 if (limit == 0) { 749 if (limit == 0) {
751 break; 750 break;
752 } 751 }
753 752
754 if (limit < (off_t) slcf->chunk_size) { 753 if (limit < (off_t) slcf->chunk_size) {
755 frame_size = limit; 754 frame_size = (size_t) limit;
756 } 755 }
757 } 756 }
758 } 757 }
759 758
760 if (offset) { 759 if (offset) {
775 } 774 }
776 775
777 776
778 static ngx_chain_t * 777 static ngx_chain_t *
779 ngx_http_spdy_filter_get_shadow(ngx_http_spdy_stream_t *stream, ngx_buf_t *buf, 778 ngx_http_spdy_filter_get_shadow(ngx_http_spdy_stream_t *stream, ngx_buf_t *buf,
780 size_t offset, size_t size) 779 off_t offset, off_t size)
781 { 780 {
782 ngx_buf_t *chunk; 781 ngx_buf_t *chunk;
783 ngx_chain_t *cl; 782 ngx_chain_t *cl;
784 783
785 cl = ngx_chain_get_free_buf(stream->request->pool, &stream->free_bufs); 784 cl = ngx_chain_get_free_buf(stream->request->pool, &stream->free_bufs);