From f263740081387b2b27086c8baa2cdbf018c78ff6 Mon Sep 17 00:00:00 2001 From: Callan Barrett Date: Tue, 21 May 2024 21:54:02 +0800 Subject: [PATCH] fix ndef bounds checking --- pkg/tokens/ndef.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/tokens/ndef.go b/pkg/tokens/ndef.go index a57f7e59..c1176152 100644 --- a/pkg/tokens/ndef.go +++ b/pkg/tokens/ndef.go @@ -43,16 +43,15 @@ func ParseRecordText(blocks []byte) (string, error) { return "", fmt.Errorf("NDEF end not found: %x", blocks) } - startIndex += 4 if startIndex >= endIndex || startIndex+4 >= len(blocks) { return "", fmt.Errorf("start index out of bounds: %d, %x", startIndex, blocks) } - if endIndex <= startIndex || endIndex+1 >= len(blocks) { + if endIndex <= startIndex || endIndex >= len(blocks) { return "", fmt.Errorf("end index out of bounds: %d, %x", endIndex, blocks) } - tagText := string(blocks[startIndex:endIndex]) + tagText := string(blocks[startIndex+4 : endIndex]) return tagText, nil }