@@ -708,6 +708,13 @@ bool make_http_soap_request(
708708 php_hash_bin2hex (cnonce , nonce , sizeof (nonce ));
709709 cnonce [32 ] = 0 ;
710710
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+
711718 if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "nc" , sizeof ("nc" )- 1 )) != NULL &&
712719 Z_TYPE_P (tmp ) == IS_LONG ) {
713720 Z_LVAL_P (tmp )++ ;
@@ -720,9 +727,8 @@ bool make_http_soap_request(
720727 PHP_MD5Init (& md5ctx );
721728 PHP_MD5Update (& md5ctx , (unsigned char * )Z_STRVAL_P (login ), Z_STRLEN_P (login ));
722729 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 ));
726732 }
727733 PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
728734 zval * password = Z_CLIENT_PASSWORD_P (this_ptr );
@@ -731,16 +737,12 @@ bool make_http_soap_request(
731737 }
732738 PHP_MD5Final (hash , & md5ctx );
733739 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" )) {
738741 PHP_MD5Init (& md5ctx );
739742 PHP_MD5Update (& md5ctx , (unsigned char * )HA1 , 32 );
740743 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 ));
744746 }
745747 PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
746748 PHP_MD5Update (& md5ctx , (unsigned char * )cnonce , 8 );
@@ -766,9 +768,8 @@ bool make_http_soap_request(
766768 PHP_MD5Init (& md5ctx );
767769 PHP_MD5Update (& md5ctx , (unsigned char * )HA1 , 32 );
768770 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 ));
772773 }
773774 PHP_MD5Update (& md5ctx , (unsigned char * )":" , 1 );
774775 if ((tmp = zend_hash_str_find (Z_ARRVAL_P (digest ), "qop" , sizeof ("qop" )- 1 )) != NULL &&
@@ -787,15 +788,13 @@ bool make_http_soap_request(
787788
788789 smart_str_append_const (& soap_headers , "Authorization: Digest username=\"" );
789790 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 ) {
792792 smart_str_append_const (& soap_headers , "\", realm=\"" );
793- smart_str_append (& soap_headers , Z_STR_P ( tmp ) );
793+ smart_str_append (& soap_headers , realm );
794794 }
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 ) {
797796 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 );
799798 }
800799 smart_str_append_const (& soap_headers , "\", uri=\"" );
801800 if (phpurl -> path ) {
@@ -827,10 +826,9 @@ bool make_http_soap_request(
827826 smart_str_append_const (& soap_headers , "\", opaque=\"" );
828827 smart_str_append (& soap_headers , Z_STR_P (tmp ));
829828 }
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 ) {
832830 smart_str_append_const (& soap_headers , "\", algorithm=\"" );
833- smart_str_append (& soap_headers , Z_STR_P ( tmp ) );
831+ smart_str_append (& soap_headers , algorithm );
834832 }
835833 smart_str_append_const (& soap_headers , "\"\r\n" );
836834 } else {
0 commit comments