@@ -708,6 +708,13 @@ bool make_http_soap_request(
708
708
php_hash_bin2hex (cnonce , nonce , sizeof (nonce ));
709
709
cnonce [32 ] = 0 ;
710
710
711
+ zval * digest_realm = zend_hash_str_find (Z_ARRVAL_P (digest ), ZEND_STRL ("realm" ));
712
+ const zend_string * realm = digest_realm && Z_TYPE_P (digest_realm ) == IS_STRING ? Z_STR_P (digest_realm ) : NULL ;
713
+ zval * digest_nonce = zend_hash_str_find (Z_ARRVAL_P (digest ), ZEND_STRL ("nonce" ));
714
+ const zend_string * nonce_zstr = digest_nonce && Z_TYPE_P (digest_nonce ) == IS_STRING ? Z_STR_P (digest_nonce ) : NULL ;
715
+ zval * digest_algorithm = zend_hash_str_find (Z_ARRVAL_P (digest ), ZEND_STRL ("algorithm" ));
716
+ const zend_string * algorithm = digest_algorithm && Z_TYPE_P (digest_algorithm ) == IS_STRING ? Z_STR_P (digest_algorithm ) : NULL ;
717
+
711
718
if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "nc" , sizeof ("nc" )- 1 )) != NULL &&
712
719
Z_TYPE_P (tmp ) == IS_LONG ) {
713
720
Z_LVAL_P (tmp )++ ;
@@ -720,9 +727,8 @@ bool make_http_soap_request(
720
727
PHP_MD5Init (& md5ctx );
721
728
PHP_MD5Update (& md5ctx , (unsigned char * )Z_STRVAL_P (login ), Z_STRLEN_P (login ));
722
729
PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
723
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "realm" , sizeof ("realm" )- 1 )) != NULL &&
724
- Z_TYPE_P (tmp ) == IS_STRING ) {
725
- PHP_MD5Update (& md5ctx , (unsigned char * )Z_STRVAL_P (tmp ), Z_STRLEN_P (tmp ));
730
+ if (realm ) {
731
+ PHP_MD5Update (& md5ctx , (unsigned char * )ZSTR_VAL (realm ), ZSTR_LEN (realm ));
726
732
}
727
733
PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
728
734
zval * password = Z_CLIENT_PASSWORD_P (this_ptr );
@@ -731,16 +737,12 @@ bool make_http_soap_request(
731
737
}
732
738
PHP_MD5Final (hash , & md5ctx );
733
739
make_digest (HA1 , hash );
734
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "algorithm" , sizeof ("algorithm" )- 1 )) != NULL &&
735
- Z_TYPE_P (tmp ) == IS_STRING &&
736
- Z_STRLEN_P (tmp ) == sizeof ("md5-sess" )- 1 &&
737
- stricmp (Z_STRVAL_P (tmp ), "md5-sess" ) == 0 ) {
740
+ if (algorithm && zend_string_equals_literal_ci (algorithm , "md5-sess" )) {
738
741
PHP_MD5Init (& md5ctx );
739
742
PHP_MD5Update (& md5ctx , (unsigned char * )HA1 , 32 );
740
743
PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
741
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "nonce" , sizeof ("nonce" )- 1 )) != NULL &&
742
- Z_TYPE_P (tmp ) == IS_STRING ) {
743
- PHP_MD5Update (& md5ctx , (unsigned char * )Z_STRVAL_P (tmp ), Z_STRLEN_P (tmp ));
744
+ if (nonce_zstr ) {
745
+ PHP_MD5Update (& md5ctx , (unsigned char * )ZSTR_VAL (nonce_zstr ), ZSTR_LEN (nonce_zstr ));
744
746
}
745
747
PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
746
748
PHP_MD5Update (& md5ctx , (unsigned char * )cnonce , 8 );
@@ -766,9 +768,8 @@ bool make_http_soap_request(
766
768
PHP_MD5Init (& md5ctx );
767
769
PHP_MD5Update (& md5ctx , (unsigned char * )HA1 , 32 );
768
770
PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
769
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "nonce" , sizeof ("nonce" )- 1 )) != NULL &&
770
- Z_TYPE_P (tmp ) == IS_STRING ) {
771
- PHP_MD5Update (& md5ctx , (unsigned char * )Z_STRVAL_P (tmp ), Z_STRLEN_P (tmp ));
771
+ if (nonce_zstr ) {
772
+ PHP_MD5Update (& md5ctx , (unsigned char * )ZSTR_VAL (nonce_zstr ), ZSTR_LEN (nonce_zstr ));
772
773
}
773
774
PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
774
775
if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "qop" , sizeof ("qop" )- 1 )) != NULL &&
@@ -787,15 +788,13 @@ bool make_http_soap_request(
787
788
788
789
smart_str_append_const (& soap_headers , "Authorization: Digest username=\"" );
789
790
smart_str_append (& soap_headers , Z_STR_P (login ));
790
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "realm" , sizeof ("realm" )- 1 )) != NULL &&
791
- Z_TYPE_P (tmp ) == IS_STRING ) {
791
+ if (realm ) {
792
792
smart_str_append_const (& soap_headers , "\", realm=\"" );
793
- smart_str_append (& soap_headers , Z_STR_P ( tmp ) );
793
+ smart_str_append (& soap_headers , realm );
794
794
}
795
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "nonce" , sizeof ("nonce" )- 1 )) != NULL &&
796
- Z_TYPE_P (tmp ) == IS_STRING ) {
795
+ if (nonce_zstr ) {
797
796
smart_str_append_const (& soap_headers , "\", nonce=\"" );
798
- smart_str_append (& soap_headers , Z_STR_P ( tmp ) );
797
+ smart_str_append (& soap_headers , nonce_zstr );
799
798
}
800
799
smart_str_append_const (& soap_headers , "\", uri=\"" );
801
800
if (phpurl -> path ) {
@@ -827,10 +826,9 @@ bool make_http_soap_request(
827
826
smart_str_append_const (& soap_headers , "\", opaque=\"" );
828
827
smart_str_append (& soap_headers , Z_STR_P (tmp ));
829
828
}
830
- if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "algorithm" , sizeof ("algorithm" )- 1 )) != NULL &&
831
- Z_TYPE_P (tmp ) == IS_STRING ) {
829
+ if (algorithm ) {
832
830
smart_str_append_const (& soap_headers , "\", algorithm=\"" );
833
- smart_str_append (& soap_headers , Z_STR_P ( tmp ) );
831
+ smart_str_append (& soap_headers , algorithm );
834
832
}
835
833
smart_str_append_const (& soap_headers , "\"\r\n" );
836
834
} else {
0 commit comments