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
dms3
go-blockservice
Commits
622c072d
Unverified
Commit
622c072d
authored
Jun 24, 2020
by
Jakub Sztandera
Committed by
GitHub
Jun 24, 2020
Browse files
Options
Browse Files
Download
Plain Diff
Merge pull request #65 from ipfs/fix/race-valid-cid
Avoid modifying passed in slice of cids
parents
f12f8ae1
5ca73b91
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
8 deletions
+17
-8
blockservice.go
blockservice.go
+17
-8
No files found.
blockservice.go
View file @
622c072d
...
...
@@ -273,17 +273,26 @@ func getBlocks(ctx context.Context, ks []cid.Cid, bs blockstore.Blockstore, fget
go
func
()
{
defer
close
(
out
)
k
:=
0
allValid
:=
true
for
_
,
c
:=
range
ks
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
==
nil
{
ks
[
k
]
=
c
k
++
}
else
{
log
.
Errorf
(
"unsafe CID (%s) passed to blockService.GetBlocks: %s"
,
c
,
err
)
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
!=
nil
{
allValid
=
false
break
}
}
ks
=
ks
[
:
k
]
if
!
allValid
{
ks2
:=
make
([]
cid
.
Cid
,
0
,
len
(
ks
))
for
_
,
c
:=
range
ks
{
// hash security
if
err
:=
verifcid
.
ValidateCid
(
c
);
err
==
nil
{
ks2
=
append
(
ks2
,
c
)
}
else
{
log
.
Errorf
(
"unsafe CID (%s) passed to blockService.GetBlocks: %s"
,
c
,
err
)
}
}
ks
=
ks2
}
var
misses
[]
cid
.
Cid
for
_
,
c
:=
range
ks
{
...
...
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