Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
ai3
accountserver
Commits
6f16cef4
Commit
6f16cef4
authored
Nov 01, 2018
by
ale
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix nil dereference
Forgot to initialize the wrapped u2f.Registration.
parent
813221d2
Pipeline
#1450
passed with stages
in 1 minute and 56 seconds
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
18 additions
and
2 deletions
+18
-2
types.go
types.go
+3
-2
types_test.go
types_test.go
+15
-0
No files found.
types.go
View file @
6f16cef4
...
...
@@ -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
)
}
types_test.go
0 → 100644
View file @
6f16cef4
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
)
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment