File tree Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Expand file tree Collapse file tree 1 file changed +13
-2
lines changed Original file line number Diff line number Diff line change @@ -367,13 +367,20 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
367367 return err
368368 }
369369 data [4 ] = cachingSha2PasswordRequestPublicKey
370- mc .writePacket (data )
370+ err = mc .writePacket (data )
371+ if err != nil {
372+ return err
373+ }
371374
372- // parse public key
373375 if data , err = mc .readPacket (); err != nil {
374376 return err
375377 }
376378
379+ if data [0 ] != iAuthMoreData {
380+ return fmt .Errorf ("unexpect resp from server for caching_sha2_password perform full authentication" )
381+ }
382+
383+ // parse public key
377384 block , rest := pem .Decode (data [1 :])
378385 if block == nil {
379386 return fmt .Errorf ("No Pem data found, data: %s" , rest )
@@ -406,6 +413,10 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
406413 return nil // auth successful
407414 default :
408415 block , _ := pem .Decode (authData )
416+ if block == nil {
417+ return fmt .Errorf ("no Pem data found, data: %s" , authData )
418+ }
419+
409420 pub , err := x509 .ParsePKIXPublicKey (block .Bytes )
410421 if err != nil {
411422 return err
You can’t perform that action at this time.
0 commit comments