@@ -969,9 +969,9 @@ typedef struct {
969969 int init ;
970970 int done ;
971971 char * buffer ;
972- apr_size_t size ;
973- apr_size_t offset ;
974- apr_size_t length ;
972+ apr_off_t size ;
973+ apr_off_t offset ;
974+ apr_off_t length ;
975975 apr_bucket_brigade * bb ;
976976 int seen_eos ;
977977 int seen_error ;
@@ -1233,11 +1233,11 @@ static apr_int64_t Input_read_from_input(InputObject *self, char *buffer,
12331233
12341234static PyObject * Input_read (InputObject * self , PyObject * args )
12351235{
1236- long size = -1 ;
1236+ apr_off_t size = -1 ;
12371237
12381238 PyObject * result = NULL ;
12391239 char * buffer = NULL ;
1240- apr_size_t length = 0 ;
1240+ apr_off_t length = 0 ;
12411241 int init = 0 ;
12421242
12431243 apr_int64_t n ;
@@ -1510,11 +1510,11 @@ static PyObject *Input_read(InputObject *self, PyObject *args)
15101510
15111511static PyObject * Input_readline (InputObject * self , PyObject * args )
15121512{
1513- long size = -1 ;
1513+ apr_off_t size = -1 ;
15141514
15151515 PyObject * result = NULL ;
15161516 char * buffer = NULL ;
1517- apr_size_t length = 0 ;
1517+ apr_off_t length = 0 ;
15181518
15191519 apr_int64_t n ;
15201520
@@ -2251,12 +2251,12 @@ static int Adapter_output(AdapterObject *self, const char *data,
22512251 ap_set_content_type (r , apr_pstrdup (r -> pool , value ));
22522252 }
22532253 else if (!strcasecmp (name , "Content-Length" )) {
2254- char * v = value ;
2255- long l = 0 ;
2254+ char * endstr ;
2255+ apr_off_t length ;
2256+
2257+ if (wsgi_strtoff (& length , value , & endstr , 10 )
2258+ || * endstr || length < 0 ) {
22562259
2257- errno = 0 ;
2258- l = strtol (v , & v , 10 );
2259- if (* v || errno == ERANGE || l < 0 ) {
22602260 PyErr_SetString (PyExc_ValueError ,
22612261 "invalid content length" );
22622262
@@ -2268,10 +2268,10 @@ static int Adapter_output(AdapterObject *self, const char *data,
22682268 return 0 ;
22692269 }
22702270
2271- ap_set_content_length (r , l );
2271+ ap_set_content_length (r , length );
22722272
22732273 self -> content_length_set = 1 ;
2274- self -> content_length = l ;
2274+ self -> content_length = length ;
22752275 }
22762276 else if (!strcasecmp (name , "WWW-Authenticate" )) {
22772277 apr_table_add (r -> err_headers_out , name , value );
@@ -2971,7 +2971,7 @@ static int Adapter_run(AdapterObject *self, PyObject *object)
29712971 PyObject * event = NULL ;
29722972
29732973 const char * msg = NULL ;
2974- long length = 0 ;
2974+ apr_off_t length = 0 ;
29752975
29762976 WSGIThreadInfo * thread_handle = NULL ;
29772977
@@ -4034,6 +4034,12 @@ static int wsgi_execute_script(request_rec *r)
40344034 apr_thread_mutex_unlock (wsgi_module_lock );
40354035#endif
40364036
4037+ /* Clear startup timeout and prevent from running again. */
4038+
4039+ #if defined(MOD_WSGI_WITH_DAEMONS )
4040+ wsgi_startup_shutdown_time = -1 ;
4041+ #endif
4042+
40374043 /* Assume an internal server error unless everything okay. */
40384044
40394045 status = HTTP_INTERNAL_SERVER_ERROR ;
@@ -4098,12 +4104,6 @@ static int wsgi_execute_script(request_rec *r)
40984104 }
40994105
41004106 Py_XDECREF ((PyObject * )adapter );
4101-
4102- /* Clear startup timeout and prevent from running again. */
4103-
4104- #if defined(MOD_WSGI_WITH_DAEMONS )
4105- wsgi_startup_shutdown_time = -1 ;
4106- #endif
41074107 }
41084108 else {
41094109 Py_BEGIN_ALLOW_THREADS
@@ -10491,12 +10491,12 @@ static apr_status_t wsgi_socket_send(apr_socket_t *sock, const char *buf,
1049110491}
1049210492
1049310493static apr_status_t wsgi_socket_sendv_limit (apr_socket_t * sock ,
10494- struct iovec * vec , int nvec )
10494+ struct iovec * vec , size_t nvec )
1049510495{
1049610496 apr_status_t rv ;
1049710497 apr_size_t written = 0 ;
1049810498 apr_size_t to_write = 0 ;
10499- int i , offset ;
10499+ size_t i , offset ;
1050010500
1050110501 /* Calculate how much has to be sent. */
1050210502
@@ -10547,7 +10547,7 @@ static apr_status_t wsgi_socket_sendv_limit(apr_socket_t *sock,
1054710547}
1054810548
1054910549static apr_status_t wsgi_socket_sendv (apr_socket_t * sock , struct iovec * vec ,
10550- int nvec )
10550+ size_t nvec )
1055110551{
1055210552#if defined(_SC_IOV_MAX )
1055310553 static size_t iov_max = 0 ;
0 commit comments