Skip to content

Commit

Permalink
update: 解析RDB格式错误处理
Browse files Browse the repository at this point in the history
  • Loading branch information
OrangeDou authored and HDT3213 committed Jul 12, 2024
1 parent 0c6b086 commit ff67ac3
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions redis/parser/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,14 @@ import (
"bufio"
"bytes"
"errors"
"github.com/hdt3213/godis/interface/redis"
"github.com/hdt3213/godis/lib/logger"
"github.com/hdt3213/godis/redis/protocol"
"io"
"runtime/debug"
"strconv"
"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
Expand Down Expand Up @@ -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
func parseRDBBulkString(reader *bufio.Reader, ch chan<- *Payload) error {
header, err := reader.ReadBytes('\n')
if err != nil {
return errors.New("failed to read bytes")
}
header = bytes.TrimSuffix(header, []byte{'\r', '\n'})
if len(header) == 0 {
return errors.New("empty header")
Expand Down

0 comments on commit ff67ac3

Please sign in to comment.