Skip to content

Commit

Permalink
[FIXED] No panic on protobuf Unmarshal errors
Browse files Browse the repository at this point in the history
Fix the Unmarshal possible overflow and also do not make the library
panic on Unmarshal errors.
We don't have a proper way to return those errors since they happen
in callbacks. For now, just printing. May add a callback error later.

Signed-off-by: Ivan Kozlovic <ivan@synadia.com>
  • Loading branch information
kozlovic committed Jan 8, 2021
1 parent 22aa6ac commit a4f322d
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 14 deletions.
24 changes: 12 additions & 12 deletions pb/protocol.pb.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 4 additions & 2 deletions stan.go
Original file line number Diff line number Diff line change
Expand Up @@ -700,7 +700,8 @@ func (sc *conn) processAck(m *nats.Msg) {
pa := &pb.PubAck{}
err := pa.Unmarshal(m.Data)
if err != nil {
panic(fmt.Errorf("error during ack unmarshal: %v", err))
fmt.Printf("error during ack unmarshal: %v\n", err)
return
}

// Remove
Expand Down Expand Up @@ -846,7 +847,8 @@ func (sc *conn) processMsg(raw *nats.Msg) {
msg := &Msg{}
err := msg.Unmarshal(raw.Data)
if err != nil {
panic(fmt.Errorf("error processing unmarshal for msg: %v", err))
fmt.Printf("error during message unmarshal: %v\n", err)
return
}
var sub *subscription
// Lookup the subscription
Expand Down

0 comments on commit a4f322d

Please sign in to comment.