Skip to content

Commit 7b629a9

Browse files
authored
handling decoding pem error (#1192)
1 parent fe2230a commit 7b629a9

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

Diff for: AUTHORS

+1
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ Thomas Wodarek <wodarekwebpage at gmail.com>
9292
Tim Ruffles <timruffles at gmail.com>
9393
Tom Jenkinson <tom at tjenkinson.me>
9494
Vladimir Kovpak <cn007b at gmail.com>
95+
Vladyslav Zhelezniak <zhvladi at gmail.com>
9596
Xiangyu Hu <xiangyu.hu at outlook.com>
9697
Xiaobing Jiang <s7v7nislands at gmail.com>
9798
Xiuming Chen <cc at cxm.cc>

Diff for: auth.go

+5-1
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ import (
1515
"crypto/sha256"
1616
"crypto/x509"
1717
"encoding/pem"
18+
"fmt"
1819
"sync"
1920
)
2021

@@ -371,7 +372,10 @@ func (mc *mysqlConn) handleAuthResult(oldAuthData []byte, plugin string) error {
371372
return err
372373
}
373374

374-
block, _ := pem.Decode(data[1:])
375+
block, rest := pem.Decode(data[1:])
376+
if block == nil {
377+
return fmt.Errorf("No Pem data found, data: %s", rest)
378+
}
375379
pkix, err := x509.ParsePKIXPublicKey(block.Bytes)
376380
if err != nil {
377381
return err

0 commit comments

Comments
 (0)