Add an ability to detect CRC32 mismatch by a checking a specific error#75
Merged
asticode merged 1 commit intoMay 5, 2026
Merged
Conversation
asticode
requested changes
May 5, 2026
Owner
asticode
left a comment
There was a problem hiding this comment.
Thanks a lot for the PR ❤️
Since errors.Join has been added in Go 1.20, go.mod needs to be updated accordingly (replace go 1.13 with go 1.20).
| PSITableIDNITVariant2 PSITableID = 0x41 | ||
| ) | ||
|
|
||
| var ErrCRC32Mismatch = errors.New("CRC32 mismatch") |
Owner
There was a problem hiding this comment.
Can you prefix the error with astits: => errors.New("astits: CRC32 mismatch")
| // Check CRC32 | ||
| if crc32 != s.CRC32 { | ||
| err = fmt.Errorf("astits: Table CRC32 %x != computed CRC32 %x", s.CRC32, crc32) | ||
| err = errors.Join(ErrCRC32Mismatch, fmt.Errorf("table CRC32 %x != computed CRC32 %x", s.CRC32, crc32)) |
Owner
There was a problem hiding this comment.
Can you keep the prefix astits: in the second error message?
| _, err := parsePSIData(astikit.NewBytesIterator(buf.Bytes())) | ||
| assert.EqualError(t, err, "astits: parsing PSI table failed: astits: Table CRC32 20 != computed CRC32 6969b13") | ||
| assert.True(t, errors.Is(err, ErrCRC32Mismatch)) | ||
| assert.Equal(t, err.Error(), "astits: parsing PSI table failed: CRC32 mismatch\ntable CRC32 20 != computed CRC32 6969b13") |
Owner
There was a problem hiding this comment.
This will need to be updated since prefixes have been added
fb13297 to
2986cc5
Compare
Contributor
Author
Fixed comments, thanks for the review |
Owner
|
Thanks a lot for the PR ❤️ Let me know whether you need a tag 👍 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Sometimes, when you are performing an AES128 decryption with the wrong parameters, it corrupts a PAT, and it would be helpful to detect such errors by checking ademuxer errors on a specific type: ErrCRC32Mismatch