@@ -804,7 +804,8 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
804
804
805
805
if (server_public_key ) {
806
806
int server_public_key_len ;
807
- char xor_str [passwd_len + 1 ];
807
+ ALLOCA_FLAG (use_heap );
808
+ char * xor_str = do_alloca (passwd_len + 1 , use_heap );
808
809
memcpy (xor_str , passwd , passwd_len );
809
810
xor_str [passwd_len ] = '\0' ;
810
811
mysqlnd_xor_string (xor_str , passwd_len , (char * ) auth_plugin_data , auth_plugin_data_len );
@@ -817,6 +818,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
817
818
*/
818
819
if ((size_t ) server_public_key_len - 41 <= passwd_len ) {
819
820
/* password message is to long */
821
+ free_alloca (xor_str , use_heap );
820
822
SET_CLIENT_ERROR (conn -> error_info , CR_UNKNOWN_ERROR , UNKNOWN_SQLSTATE , "password is too long" );
821
823
DBG_ERR ("password is too long" );
822
824
DBG_RETURN (NULL );
@@ -826,6 +828,7 @@ mysqlnd_sha256_auth_get_auth_data(struct st_mysqlnd_authentication_plugin * self
826
828
ret = malloc (* auth_data_len );
827
829
RSA_public_encrypt (passwd_len + 1 , (zend_uchar * ) xor_str , ret , server_public_key , RSA_PKCS1_OAEP_PADDING );
828
830
RSA_free (server_public_key );
831
+ free_alloca (xor_str , use_heap );
829
832
}
830
833
}
831
834
@@ -1023,7 +1026,8 @@ mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
1023
1026
1024
1027
if (server_public_key ) {
1025
1028
int server_public_key_len ;
1026
- char xor_str [passwd_len + 1 ];
1029
+ ALLOCA_FLAG (use_heap )
1030
+ char * xor_str = do_alloca (passwd_len + 1 , use_heap );
1027
1031
memcpy (xor_str , passwd , passwd_len );
1028
1032
xor_str [passwd_len ] = '\0' ;
1029
1033
mysqlnd_xor_string (xor_str , passwd_len , (char * ) auth_plugin_data , SCRAMBLE_LENGTH );
@@ -1036,13 +1040,15 @@ mysqlnd_caching_sha2_get_and_use_key(MYSQLND_CONN_DATA *conn,
1036
1040
*/
1037
1041
if ((size_t ) server_public_key_len - 41 <= passwd_len ) {
1038
1042
/* password message is to long */
1043
+ free_alloca (xor_str , use_heap );
1039
1044
SET_CLIENT_ERROR (conn -> error_info , CR_UNKNOWN_ERROR , UNKNOWN_SQLSTATE , "password is too long" );
1040
1045
DBG_ERR ("password is too long" );
1041
1046
DBG_RETURN (0 );
1042
1047
}
1043
1048
1044
1049
* crypted = emalloc (server_public_key_len );
1045
1050
RSA_public_encrypt (passwd_len + 1 , (zend_uchar * ) xor_str , * crypted , server_public_key , RSA_PKCS1_OAEP_PADDING );
1051
+ free_alloca (xor_str , use_heap );
1046
1052
DBG_RETURN (server_public_key_len );
1047
1053
}
1048
1054
DBG_RETURN (0 );
0 commit comments