File tree Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Expand file tree Collapse file tree 1 file changed +12
-14
lines changed Original file line number Diff line number Diff line change @@ -456,12 +456,18 @@ func (a *AttestationBundle) Add(env *provenance.Envelope) error {
456
456
// This function ensures entries are unique.
457
457
// This function is not synchronised.
458
458
func (a * AttestationBundle ) AddFromBundle (other io.Reader ) error {
459
- // TOOD(cw): use something other than a scanner. We've seen "Token Too Long" in first trials already.
460
- scan := bufio .NewScanner (other )
461
- scan .Buffer (make ([]byte , maxBundleEntrySize ), maxBundleEntrySize )
462
- for scan .Scan () {
459
+ reader := bufio .NewReader (other )
460
+ for {
461
+ line , err := reader .ReadBytes ('\n' )
462
+ if err != nil {
463
+ if err == io .EOF {
464
+ break
465
+ }
466
+ return err
467
+ }
468
+
463
469
hash := sha256 .New ()
464
- _ , err : = hash .Write (scan . Bytes () )
470
+ _ , err = hash .Write (line )
465
471
if err != nil {
466
472
return err
467
473
}
@@ -471,20 +477,12 @@ func (a *AttestationBundle) AddFromBundle(other io.Reader) error {
471
477
continue
472
478
}
473
479
474
- _ , err = a .out .Write (scan .Bytes ())
475
- if err != nil {
476
- return err
477
- }
478
- _ , err = a .out .Write ([]byte {'\n' })
480
+ _ , err = a .out .Write (line )
479
481
if err != nil {
480
482
return err
481
483
}
482
484
a .keys [key ] = struct {}{}
483
485
}
484
-
485
- if scan .Err () != nil {
486
- return scan .Err ()
487
- }
488
486
return nil
489
487
}
490
488
You can’t perform that action at this time.
0 commit comments