Skip to content

Commit

Permalink
lnwire: don't attempt to decode an empty/nil signature
Browse files Browse the repository at this point in the history
  • Loading branch information
Roasbeef committed Jun 8, 2018
1 parent 4bde4c1 commit 15f812b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
8 changes: 8 additions & 0 deletions lnwire/signature.go
Expand Up @@ -17,6 +17,10 @@ type Sig [64]byte
func NewSigFromRawSignature(sig []byte) (Sig, error) {
var b Sig

if len(sig) == 0 {
return b, fmt.Errorf("cannot decode empty signature")
}

// Extract lengths of R and S. The DER representation is laid out as
// 0x30 <length> 0x02 <length r> r 0x02 <length s> s
// which means the length of R is the 4th byte and the length of S
Expand Down Expand Up @@ -61,6 +65,10 @@ func NewSigFromRawSignature(sig []byte) (Sig, error) {
// NewSigFromSignature creates a new signature as used on the wire, from an
// existing btcec.Signature.
func NewSigFromSignature(e *btcec.Signature) (Sig, error) {
if e == nil {
return Sig{}, fmt.Errorf("cannot decode empty signature")
}

// Serialize the signature with all the checks that entails.
return NewSigFromRawSignature(e.Serialize())
}
Expand Down
1 change: 0 additions & 1 deletion rpcserver.go
Expand Up @@ -2186,7 +2186,6 @@ func (r *rpcServer) sendPayment(stream *paymentStream) error {
PaymentRoute: marshallRoute(route),
})
if err != nil {
rpcsLog.Infof("sender rrrrr: ", err)
errChan <- err
return
}
Expand Down

0 comments on commit 15f812b

Please sign in to comment.