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 {
456456// This function ensures entries are unique.
457457// This function is not synchronised.
458458func (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+
463469 hash := sha256 .New ()
464- _ , err : = hash .Write (scan . Bytes () )
470+ _ , err = hash .Write (line )
465471 if err != nil {
466472 return err
467473 }
@@ -471,20 +477,12 @@ func (a *AttestationBundle) AddFromBundle(other io.Reader) error {
471477 continue
472478 }
473479
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 )
479481 if err != nil {
480482 return err
481483 }
482484 a .keys [key ] = struct {}{}
483485 }
484-
485- if scan .Err () != nil {
486- return scan .Err ()
487- }
488486 return nil
489487}
490488
You can’t perform that action at this time.
0 commit comments