github-vet / github-vet/rangeloop-pointer-findings
ldsec/drynx: protocols/data_collection_protocol.go; 96 LoC
- Dominant language
- No language data
- Stars
- 0
- Forks
- 0
- PR merge metrics
- PR metrics pending
Description
Found a possible issue in [ldsec/drynx](https://www.github.com/ldsec/drynx) at [protocols/data_collection_protocol.go](https://github.com/ldsec/drynx/blob/56741b2d01f9db6c0e9059caf33ccc7cf56974cc/protocols/data_collection_protocol.go#L254-L349)
Below is the message reported by the analyzer for this snippet of code. Beware that the analyzer only reports the first
issue it finds, so please do not limit your consideration to the contents of the below message.
> range-loop variable v used in defer or goroutine at line 287
[Click here to see the code in its original context.](https://github.com/ldsec/drynx/blob/56741b2d01f9db6c0e9059caf33ccc7cf56974cc/protocols/data_collection_protocol.go#L254-L349)
Click here to show the 96 line(s) of Go which triggered the analyzer.
```go
for _, v := range groupsString {
if p.Survey.Query.CuttingFactor != 0 {
p.Survey.Query.Operation.NbrOutput = int(p.Survey.Query.Operation.NbrOutput / p.Survey.Query.CuttingFactor)
}
if p.Survey.Query.Operation.NameOp == "logistic regression" {
//p.Survey.Query.Ranges = nil
var err error
encryptedResponse, clearResponse, cprf, err = libdrynxencoding.EncodeForFloat(xFloat, yInt, lrParameters, p.Survey.Aggregate, signatures, p.Survey.Query.Ranges, p.Survey.Query.Operation.NameOp)
if err != nil {
return libdrynx.ResponseDPBytes{}, fmt.Errorf("when getting data for provider: %w", err)
}
} else {
encryptedResponse, clearResponse, cprf = libdrynxencoding.Encode(fakeData, p.Survey.Aggregate, signatures, p.Survey.Query.Ranges, p.Survey.Query.Operation)
}
log.Lvl2("Data Provider", p.Name(), "computes the query response", clearResponse, "for groups:", groupsString, "with operation:", p.Survey.Query.Operation)
queryResponse[v] = libunlynx.CipherVector(encryptedResponse)
// scaling for simulation purposes
qr := queryResponse[v]
for i := 0; i < p.Survey.Query.CuttingFactor-1; i++ {
queryResponse[v] = append(queryResponse[v], qr...)
}
if p.Survey.Query.Proofs != 0 {
go func() {
startAllProofs := libunlynx.StartTimer(p.Name() + "_AllProofs")
rpl := libdrynxrange.RangeProofList{}
//rangeProofCreation := libunlynx.StartTimer(p.Name() + "_RangeProofCreation")
// no range proofs (send only the ciphertexts)
if len(cprf) == 0 {
tmp := make([]libdrynxrange.RangeProof, 0)
for _, ct := range queryResponse[v] {
tmp = append(tmp, libdrynxrange.RangeProof{Commit: ct, RP: nil})
}
rpl = libdrynxrange.RangeProofList{Data: tmp}
} else { // if range proofs
rpl = libdrynxrange.RangeProofList{Data: libdrynxrange.CreatePredicateRangeProofListForAllServers(cprf)}
}
// scaling for simulation purposes
if p.Survey.Query.CuttingFactor != 0 {
rplNew := libdrynxrange.RangeProofList{}
rplNew.Data = make([]libdrynxrange.RangeProof, len(rpl.Data)*p.Survey.Query.CuttingFactor)
counter := 0
suitePair := bn256.NewSuite()
for j := 0; j < p.Survey.Query.CuttingFactor; j++ {
for _, v := range rpl.Data {
rplNew.Data[counter].RP = &libdrynxrange.RangeProofData{}
rplNew.Data[counter].RP.V = make([][]kyber.Point, len(v.RP.V))
for k, w := range v.RP.V {
rplNew.Data[counter].RP.V[k] = make([]kyber.Point, len(w))
for l, x := range w {
tmp := suitePair.G2().Point().Null()
tmp.Add(tmp, x)
rplNew.Data[counter].RP.V[k][l] = tmp
}
}
//rplNew.Data[counter].RP.V = tmp.Add(tmp,v.RP.V)
rplNew.Data[counter].RP.Zv = v.RP.Zv
rplNew.Data[counter].RP.Zr = v.RP.Zr
rplNew.Data[counter].RP.Challenge = v.RP.Challenge
rplNew.Data[counter].RP.D = v.RP.D
rplNew.Data[counter].RP.Zphi = v.RP.Zphi
rplNew.Data[counter].RP.A = v.RP.A
//rplNew.Data[counter].RP. = &newRpd
rplNew.Data[counter].Commit = v.Commit
counter = counter + 1
}
}
rpl.Data = rplNew.Data
}
pi := p.MapPIs["range/"+p.ServerIdentity().String()]
pi.(*ProofCollectionProtocol).Proof = drynxproof.ProofRequest{RangeProof: drynxproof.NewRangeProofRequest(&rpl, p.Survey.SurveyID, p.ServerIdentity().String(), "", p.Survey.Query.RosterVNs, p.Private(), nil)}
//libunlynx.EndTimer(rangeProofCreation)
go func() {
if err := pi.Dispatch(); err != nil {
log.Fatal(err)
}
}()
go func() {
if err := pi.Start(); err != nil {
log.Fatal(err)
}
}()
<-pi.(*ProofCollectionProtocol).FeedbackChannel
libunlynx.EndTimer(startAllProofs)
}()
}
}
```
Leave a reaction on this issue to contribute to the project by classifying this instance as a **Bug** :-1:, **Mitigated** :+1:, or **Desirable Behavior** :rocket:
See the descriptions of the classifications [here](https://github.com/github-vet/rangeclosure-findings#how-can-i-help) for more information.
commit ID: 56741b2d01f9db6c0e9059caf33ccc7cf56974cc
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.