@@ -1736,15 +1736,15 @@ static int php_openssl_enable_crypto(php_stream *stream,
17361736 return -1 ;
17371737}
17381738
1739- static size_t php_openssl_sockop_write (php_stream * stream , const char * buf , size_t count ) /* {{{ */
1739+ static size_t php_openssl_sockop_read (php_stream * stream , char * buf , size_t count ) /* {{{ */
17401740{
1741- return php_openssl_sockop_io ( 0 , stream , ( char * ) buf , count );
1741+ return php_openssl_sockop_io ( 1 , stream , buf , count );
17421742}
17431743/* }}} */
17441744
1745- static size_t php_openssl_sockop_read (php_stream * stream , char * buf , size_t count ) /* {{{ */
1745+ static size_t php_openssl_sockop_write (php_stream * stream , const char * buf , size_t count ) /* {{{ */
17461746{
1747- return php_openssl_sockop_io ( 1 , stream , buf , count );
1747+ return php_openssl_sockop_io ( 0 , stream , ( char * ) buf , count );
17481748}
17491749/* }}} */
17501750
@@ -1762,10 +1762,10 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
17621762 /* Only do this if SSL is active. */
17631763 if (sslsock -> ssl_active ) {
17641764 int retry = 1 ;
1765- struct timeval start_time ,
1766- * timeout ;
1767- int blocked = sslsock -> s .is_blocked ,
1768- has_timeout = 0 ;
1765+ struct timeval start_time ;
1766+ struct timeval * timeout ;
1767+ int blocked = sslsock -> s .is_blocked ;
1768+ int has_timeout = 0 ;
17691769 int nr_bytes = 0 ;
17701770
17711771 /* prevent overflow in openssl */
@@ -1812,7 +1812,7 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
18121812 /* Now, do the IO operation. Don't block if we can't complete... */
18131813 if (read ) {
18141814 nr_bytes = SSL_read (sslsock -> ssl_handle , buf , (int )count );
1815-
1815+
18161816 if (sslsock -> reneg && sslsock -> reneg -> should_close ) {
18171817 /* renegotiation rate limiting triggered */
18181818 php_stream_xport_shutdown (stream , (stream_shutdown_t )SHUT_RDWR );
@@ -1840,7 +1840,7 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
18401840 if (errno == EAGAIN && err == SSL_ERROR_WANT_READ && read ) {
18411841 retry = 1 ;
18421842 }
1843- if (errno == EAGAIN && SSL_ERROR_WANT_WRITE && read == 0 ) {
1843+ if (errno == EAGAIN && SSL_ERROR_WANT_WRITE && read == 0 ) {
18441844 retry = 1 ;
18451845 }
18461846
@@ -1863,7 +1863,7 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
18631863 }
18641864 } else {
18651865 /* Else, if we got bytes back, check for possible errors. */
1866- int err = SSL_get_error (sslsock -> ssl_handle , nr_bytes );
1866+ int err = SSL_get_error (sslsock -> ssl_handle , nr_bytes );
18671867
18681868 /* If we didn't get any error, then let's return it to PHP. */
18691869 if (err == SSL_ERROR_NONE ) {
@@ -1884,7 +1884,7 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
18841884
18851885 /* Finally, we keep going until we got data, and an SSL_ERROR_NONE, unless we had an error. */
18861886 } while (retry );
1887-
1887+
18881888 /* Tell PHP if we read / wrote bytes. */
18891889 if (nr_bytes > 0 ) {
18901890 php_stream_notify_progress_increment (PHP_STREAM_CONTEXT (stream ), nr_bytes , 0 );
@@ -1893,15 +1893,15 @@ static size_t php_openssl_sockop_io(int read, php_stream *stream, char *buf, siz
18931893 /* And if we were originally supposed to be blocking, let's reset the socket to that. */
18941894 if (blocked ) {
18951895 php_set_sock_blocking (sslsock -> s .socket , 1 );
1896- sslsock -> s .is_blocked = 1 ;
1896+ sslsock -> s .is_blocked = 1 ;
18971897 }
18981898
18991899 return 0 > nr_bytes ? 0 : nr_bytes ;
19001900 } else {
19011901 size_t nr_bytes = 0 ;
19021902
19031903 /*
1904- * This block is if we had no timeout... We will just sit and wait forever on the IO operation.
1904+ * This block is if we had no timeout... We will just sit and wait forever on the IO operation.
19051905 */
19061906 if (read ) {
19071907 nr_bytes = php_stream_socket_ops .read (stream , buf , count );
@@ -2260,7 +2260,7 @@ static zend_long get_crypto_method(php_stream_context *ctx, zend_long crypto_met
22602260 if (ctx && (val = php_stream_context_get_option (ctx , "ssl" , "crypto_method" )) != NULL ) {
22612261 convert_to_long_ex (val );
22622262 crypto_method = (zend_long )Z_LVAL_P (val );
2263- crypto_method |= STREAM_CRYPTO_IS_CLIENT ;
2263+ crypto_method |= STREAM_CRYPTO_IS_CLIENT ;
22642264 }
22652265
22662266 return crypto_method ;
@@ -2397,4 +2397,4 @@ php_stream *php_openssl_ssl_socket_factory(const char *proto, size_t protolen,
23972397 * End:
23982398 * vim600: noet sw=4 ts=4 fdm=marker
23992399 * vim<600: noet sw=4 ts=4
2400- */
2400+ */
0 commit comments