mirror of
https://github.com/HDT3213/godis.git
synced 2025-10-06 01:07:06 +08:00
update: 解析RDB格式错误处理
This commit is contained in:
@@ -4,13 +4,14 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"bytes"
|
"bytes"
|
||||||
"errors"
|
"errors"
|
||||||
"github.com/hdt3213/godis/interface/redis"
|
|
||||||
"github.com/hdt3213/godis/lib/logger"
|
|
||||||
"github.com/hdt3213/godis/redis/protocol"
|
|
||||||
"io"
|
"io"
|
||||||
"runtime/debug"
|
"runtime/debug"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
"github.com/hdt3213/godis/interface/redis"
|
||||||
|
"github.com/hdt3213/godis/lib/logger"
|
||||||
|
"github.com/hdt3213/godis/redis/protocol"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Payload stores redis.Reply or error
|
// Payload stores redis.Reply or error
|
||||||
@@ -155,6 +156,9 @@ func parseBulkString(header []byte, reader *bufio.Reader, ch chan<- *Payload) er
|
|||||||
// there is no CRLF between RDB and following AOF, therefore it needs to be treated differently
|
// there is no CRLF between RDB and following AOF, therefore it needs to be treated differently
|
||||||
func parseRDBBulkString(reader *bufio.Reader, ch chan<- *Payload) error {
|
func parseRDBBulkString(reader *bufio.Reader, ch chan<- *Payload) error {
|
||||||
header, err := reader.ReadBytes('\n')
|
header, err := reader.ReadBytes('\n')
|
||||||
|
if err != nil {
|
||||||
|
return errors.New("failed to read bytes")
|
||||||
|
}
|
||||||
header = bytes.TrimSuffix(header, []byte{'\r', '\n'})
|
header = bytes.TrimSuffix(header, []byte{'\r', '\n'})
|
||||||
if len(header) == 0 {
|
if len(header) == 0 {
|
||||||
return errors.New("empty header")
|
return errors.New("empty header")
|
||||||
|
Reference in New Issue
Block a user