fix(OtherFunctions): correct base16 decode, base64 footer append, duplicate .asf entry, mp3 comment - #30
Merged
Conversation
…licate .asf - base16Lookup entries for ':' through '@' were incorrectly mapped to 0x9; they are not valid hex digits so map them to the 0xFF invalid sentinel - DecodeBase16 did not check for the 0xFF sentinel before writing to the output buffer, causing silent corruption on invalid input; add guard - EncodeBase64 used assignment instead of append when writing the footer line, discarding all encoded content (pbBufferOut = → +=) - ED2KFileTypesMap inserted ".asf" twice; remove the duplicate entry
MP3 is MPEG-1 Audio Layer 3 (or MPEG-2 Audio Layer 3), not "MPEG-3".
…64 encode Add OtherFunctionsTest covering: - DecodeBase16 round-trip correctness - DecodeBase16 returning 0 on non-hex characters ':' through '@' - DecodeBase16 returning 0 on odd-length input - EncodeBase64 preserving encoded content when a PEM header is set Add SetBase64Header() to expose the file-static strHeaderLine so the PEM header/footer path of EncodeBase64 can be exercised from tests.
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.
Summary
base16Lookupmapped':'through'@'(ASCII 58–64) to0x9; these are not valid hex digits and fall within the valid lookup range, so they bypassed the out-of-range guard and silently produced wrong output. Fixed by mapping them to the0xFFinvalid sentinel, and added a guard inDecodeBase16to return 0 on the first invalid character.EncodeBase64used=instead of+=when appending the-----END ...-----footer, discarding all previously encoded data. Fixed to+=..asfmap entry:ED2KFileTypesMapinserted.asftwice. Removed the second entry..mp3comment:// MPEG-3 Audio Filecorrected to// MPEG-1/2 Audio Layer 3 File.Tests added
Added
unittests/tests/OtherFunctionsTest.cppwith five cases, verified to fail against the pre-fix code and pass after:Base16/RoundTripEncodeBase16+DecodeBase16round-trip on0xDEADBEEFBase16/RejectsNonHexCharsDecodeBase16returns 0 for each of':'';''<''=''>''?''@'Base16/RejectsOddLengthDecodeBase16returns 0 for odd-length inputBase64/HeaderAndFooterBothPresentEncodeBase64with header"TEST"on input"Man"produces output containing-----BEGIN TEST-----,TWFu, and-----END TEST-----in orderBase64/NoHeaderProducesPlainBase64SetBase64Header()was added toOtherFunctions.h/.cppto expose the file-staticstrHeaderLinefor test setup.Test plan
OtherFunctionsTestpasses (ctest -R OtherFunctionsTest)