@@ -2186,7 +2186,8 @@ static PyObject *
2186
2186
_ssl__SSLSocket_write_impl (PySSLSocket * self , Py_buffer * b )
2187
2187
/*[clinic end generated code: output=aa7a6be5527358d8 input=77262d994fe5100a]*/
2188
2188
{
2189
- int len ;
2189
+ size_t count = 0 ;
2190
+ int retval ;
2190
2191
int sockstate ;
2191
2192
_PySSLError err ;
2192
2193
int nonblocking ;
@@ -2204,12 +2205,6 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
2204
2205
Py_INCREF (sock );
2205
2206
}
2206
2207
2207
- if (b -> len > INT_MAX ) {
2208
- PyErr_Format (PyExc_OverflowError ,
2209
- "string longer than %d bytes" , INT_MAX );
2210
- goto error ;
2211
- }
2212
-
2213
2208
if (sock != NULL ) {
2214
2209
/* just in case the blocking state of the socket has been changed */
2215
2210
nonblocking = (sock -> sock_timeout >= 0 );
@@ -2239,8 +2234,8 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
2239
2234
2240
2235
do {
2241
2236
PySSL_BEGIN_ALLOW_THREADS
2242
- len = SSL_write (self -> ssl , b -> buf , (int )b -> len );
2243
- err = _PySSL_errno (len <= 0 , self -> ssl , len );
2237
+ retval = SSL_write_ex (self -> ssl , b -> buf , (int )b -> len , & count );
2238
+ err = _PySSL_errno (retval == 0 , self -> ssl , retval );
2244
2239
PySSL_END_ALLOW_THREADS
2245
2240
self -> err = err ;
2246
2241
@@ -2273,11 +2268,11 @@ _ssl__SSLSocket_write_impl(PySSLSocket *self, Py_buffer *b)
2273
2268
err .ssl == SSL_ERROR_WANT_WRITE );
2274
2269
2275
2270
Py_XDECREF (sock );
2276
- if (len < = 0 )
2277
- return PySSL_SetError (self , len , __FILE__ , __LINE__ );
2271
+ if (retval = = 0 )
2272
+ return PySSL_SetError (self , retval , __FILE__ , __LINE__ );
2278
2273
if (PySSL_ChainExceptions (self ) < 0 )
2279
2274
return NULL ;
2280
- return PyLong_FromLong ( len );
2275
+ return PyLong_FromSize_t ( count );
2281
2276
error :
2282
2277
Py_XDECREF (sock );
2283
2278
PySSL_ChainExceptions (self );
@@ -2327,7 +2322,8 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
2327
2322
{
2328
2323
PyObject * dest = NULL ;
2329
2324
char * mem ;
2330
- int count ;
2325
+ size_t count = 0 ;
2326
+ int retval ;
2331
2327
int sockstate ;
2332
2328
_PySSLError err ;
2333
2329
int nonblocking ;
@@ -2390,8 +2386,8 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
2390
2386
2391
2387
do {
2392
2388
PySSL_BEGIN_ALLOW_THREADS
2393
- count = SSL_read (self -> ssl , mem , len );
2394
- err = _PySSL_errno (count <= 0 , self -> ssl , count );
2389
+ retval = SSL_read_ex (self -> ssl , mem , len , & count );
2390
+ err = _PySSL_errno (retval == 0 , self -> ssl , retval );
2395
2391
PySSL_END_ALLOW_THREADS
2396
2392
self -> err = err ;
2397
2393
@@ -2424,8 +2420,8 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
2424
2420
} while (err .ssl == SSL_ERROR_WANT_READ ||
2425
2421
err .ssl == SSL_ERROR_WANT_WRITE );
2426
2422
2427
- if (count < = 0 ) {
2428
- PySSL_SetError (self , count , __FILE__ , __LINE__ );
2423
+ if (retval = = 0 ) {
2424
+ PySSL_SetError (self , retval , __FILE__ , __LINE__ );
2429
2425
goto error ;
2430
2426
}
2431
2427
if (self -> exc_type != NULL )
@@ -2438,7 +2434,7 @@ _ssl__SSLSocket_read_impl(PySSLSocket *self, int len, int group_right_1,
2438
2434
return dest ;
2439
2435
}
2440
2436
else {
2441
- return PyLong_FromLong (count );
2437
+ return PyLong_FromSize_t (count );
2442
2438
}
2443
2439
2444
2440
error :
0 commit comments