Skip to content

Commit 124b7ac

Browse files
committed
Don't get fooled by the match
1 parent 8cbb844 commit 124b7ac

File tree

1 file changed

+6
-7
lines changed

1 file changed

+6
-7
lines changed

components/ee/agent-smith/pkg/classifier/sinature.go

Lines changed: 6 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,12 @@ func (s *Signature) matchTextFile(in *SignatureReadCache) (bool, error) {
313313
pos := s.Slice.Start
314314
for {
315315
n, err := in.Reader.ReadAt(buffer, pos)
316+
if err == io.EOF {
317+
break
318+
}
319+
if err != nil {
320+
return false, xerrors.Errorf("cannot read stream: %w", err)
321+
}
316322
sub := buffer[0:n]
317323
pos += int64(n)
318324

@@ -323,13 +329,6 @@ func (s *Signature) matchTextFile(in *SignatureReadCache) (bool, error) {
323329
if match {
324330
return true, nil
325331
}
326-
327-
if err == io.EOF {
328-
break
329-
}
330-
if err != nil {
331-
return false, xerrors.Errorf("cannot read stream: %w", err)
332-
}
333332
if s.Slice.End > 0 && pos >= s.Slice.End {
334333
break
335334
}

0 commit comments

Comments
 (0)