SherClockHolmes / webpush-go

Web Push API Encryption with VAPID support.
MIT License
312 stars 67 forks source link

SendNotification returns nil error value in error case #7

Closed EmpireJones closed 6 years ago

EmpireJones commented 6 years ago

There is at least one case in the SendNotification function of webpush.go in which a nil error value may be returned in an error state:

    // Shared secret
    publicKeyX, publicKeyY := elliptic.Unmarshal(curve, clientPublicKey)
    if publicKeyY == nil {
        return &http.Response{}, err
    }

A new error should be returned for this case; otherwise, the consuming project may incorrectly assume that the Response is valid.

Additionally, the comments from elliptic.Unmarshal indicate that the x value would be null in the case of an error, but this code is checking the y value. This may or may not be ok to do.

SherClockHolmes commented 6 years ago

Thanks again @EmpireJones, I have pushed a fix to master.