Commit 6f16cef4 authored by ale's avatar ale

Fix nil dereference

Forgot to initialize the wrapped u2f.Registration.
parent 813221d2
Pipeline #1450 passed with stages
in 1 minute and 56 seconds
......@@ -418,7 +418,7 @@ type U2FRegistration struct {
// MarshalJSON implements the json.Marshaler interface.
func (r *U2FRegistration) MarshalJSON() ([]byte, error) {
data, err := r.MarshalBinary()
data, err := r.Registration.MarshalBinary()
if err != nil {
return nil, err
}
......@@ -434,5 +434,6 @@ func (r *U2FRegistration) UnmarshalJSON(data []byte) error {
if err := json.Unmarshal(data, &b); err != nil {
return err
}
return r.UnmarshalBinary(b)
r.Registration = new(u2f.Registration)
return r.Registration.UnmarshalBinary(b)
}
package accountserver
import (
"encoding/json"
"testing"
)
var testReg = `"BQRymreLJraApU27oZ0dpjFW7VsjwfRUwblUfhEPUr9zOiryBSvCmVAL0pqJAMuV70qu6U0t70hMo0cUxec0evdKQFlPUJcS2P0HgoyNq8JHGQ5LjF26gbYRDSkCmdqxjP/i8lPSTiFqAucnLhAhQaAw7khfLJ3nszzNNCrgExmE6ocwggGHMIIBLqADAgECAgkAmb7osQyi7BwwCQYHKoZIzj0EATAhMR8wHQYDVQQDDBZZdWJpY28gVTJGIFNvZnQgRGV2aWNlMB4XDTEzMDcxNzE0MjEwM1oXDTE2MDcxNjE0MjEwM1owITEfMB0GA1UEAwwWWXViaWNvIFUyRiBTb2Z0IERldmljZTBZMBMGByqGSM49AgEGCCqGSM49AwEHA0IABDvhl91zfpg9n7DeCedcQ8gGXUnemiXoi+JEAxz+EIhkVsMPAyzhtJZ4V3CqMZ+MOUgICt2aMxacMX9cIa8dgS2jUDBOMB0GA1UdDgQWBBQNqL+TV04iaO6mS5tjGE6ShfexnjAfBgNVHSMEGDAWgBQNqL+TV04iaO6mS5tjGE6ShfexnjAMBgNVHRMEBTADAQH/MAkGByqGSM49BAEDSAAwRQIgXJWZdbvOWdhVaG7IJtn44o21Kmi8EHsDk4cAfnZ0r38CIQD6ZPi3Pl4lXxbY7BXFyrpkiOvCpdyNdLLYbSTbvIBQOTBGAiEA2oN5nlqtnpgV2UQNv2bIa29vyoTB+oBj9xkaGU8Ozm8CIQDueoTlbdFV7sLLMpj5jwpqktwl6UiPZnmQtpUyYmc21w=="`
func TestU2FRegistration_Unmarshal(t *testing.T) {
var reg U2FRegistration
if err := json.Unmarshal([]byte(testReg), &reg); err != nil {
t.Fatal(err)
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment