Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
client
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Terraform modules
Analyze
Contributor analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
elixxir
client
Commits
a4f631ed
Commit
a4f631ed
authored
4 years ago
by
Jono Wenger
Browse files
Options
Downloads
Patches
Plain Diff
Check size of provided data to Contact marshal
parent
485e942e
No related branches found
No related tags found
No related merge requests found
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
cmd/root.go
+3
-3
3 additions, 3 deletions
cmd/root.go
interfaces/contact/contact.go
+6
-0
6 additions, 0 deletions
interfaces/contact/contact.go
with
9 additions
and
3 deletions
cmd/root.go
+
3
−
3
View file @
a4f631ed
...
...
@@ -251,13 +251,13 @@ func readContact() contact.Contact {
return
contact
.
Contact
{}
}
data
,
err
:=
ioutil
.
ReadFile
(
inputFilePath
)
jww
.
INFO
.
Printf
(
"
S
ize read in: %d"
,
len
(
data
))
jww
.
INFO
.
Printf
(
"
Contact file s
ize read in: %d"
,
len
(
data
))
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"
Failed to read contact file:
%+v"
,
err
)
}
c
,
err
:=
contact
.
Unmarshal
(
data
)
if
err
!=
nil
{
jww
.
FATAL
.
Panicf
(
"%+v"
,
err
)
jww
.
FATAL
.
Panicf
(
"
Failed to unmarshal contact:
%+v"
,
err
)
}
return
c
}
...
...
This diff is collapsed.
Click to expand it.
interfaces/contact/contact.go
+
6
−
0
View file @
a4f631ed
...
...
@@ -79,6 +79,12 @@ func (c Contact) Marshal() []byte {
// Unmarshal decodes the byte slice produced by Contact.Marshal into a Contact.
func
Unmarshal
(
b
[]
byte
)
(
Contact
,
error
)
{
if
len
(
b
)
<
sizeByteLength
*
3
+
id
.
ArrIDLen
{
return
Contact
{},
errors
.
Errorf
(
"Length of provided buffer (%d) too "
+
"short; length must be at least %d."
,
len
(
b
),
sizeByteLength
*
3
+
id
.
ArrIDLen
)
}
c
:=
Contact
{
DhPubKey
:
&
cyclic
.
Int
{}}
var
err
error
buff
:=
bytes
.
NewBuffer
(
b
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment