File tree 1 file changed +13
-2
lines changed
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 {
367
367
return err
368
368
}
369
369
data [4 ] = cachingSha2PasswordRequestPublicKey
370
- mc .writePacket (data )
370
+ err = mc .writePacket (data )
371
+ if err != nil {
372
+ return err
373
+ }
371
374
372
- // parse public key
373
375
if data , err = mc .readPacket (); err != nil {
374
376
return err
375
377
}
376
378
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
377
384
block , rest := pem .Decode (data [1 :])
378
385
if block == nil {
379
386
return fmt .Errorf ("No Pem data found, data: %s" , rest )
@@ -406,6 +413,10 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
406
413
return nil // auth successful
407
414
default :
408
415
block , _ := pem .Decode (authData )
416
+ if block == nil {
417
+ return fmt .Errorf ("no Pem data found, data: %s" , authData )
418
+ }
419
+
409
420
pub , err := x509 .ParsePKIXPublicKey (block .Bytes )
410
421
if err != nil {
411
422
return err
You can’t perform that action at this time.
0 commit comments