Attestation Verification - Buffer Fix (#9198)
* swap scanner to readline for attestations * replace readLine with readBytes
This commit is contained in:
parent
5e7ba54b56
commit
c572383bda
1 changed files with 7 additions and 7 deletions
|
|
@ -73,21 +73,21 @@ func loadBundlesFromJSONLinesFile(path string) ([]*api.Attestation, error) {
|
|||
|
||||
attestations := []*api.Attestation{}
|
||||
|
||||
scanner := bufio.NewScanner(file)
|
||||
for scanner.Scan() {
|
||||
b := scanner.Bytes()
|
||||
reader := bufio.NewReader(file)
|
||||
|
||||
var line []byte
|
||||
line, err = reader.ReadBytes('\n')
|
||||
for err == nil {
|
||||
var bundle bundle.ProtobufBundle
|
||||
bundle.Bundle = new(protobundle.Bundle)
|
||||
err = bundle.UnmarshalJSON(b)
|
||||
err = bundle.UnmarshalJSON(line)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("failed to unmarshal bundle from JSON: %v", err)
|
||||
}
|
||||
a := api.Attestation{Bundle: &bundle}
|
||||
attestations = append(attestations, &a)
|
||||
}
|
||||
|
||||
if err := scanner.Err(); err != nil {
|
||||
return nil, err
|
||||
line, err = reader.ReadBytes('\n')
|
||||
}
|
||||
|
||||
return attestations, nil
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue