Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cherrypick into 1.3: Fix off-by-one in look checks for QName iterators. #33279

Merged
merged 1 commit into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/lib/dnssd/minimal_mdns/core/QName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ bool SerializedQNameIterator::Next(bool followIndirectPointers)
}

size_t offset = static_cast<size_t>(((*mCurrentPosition & 0x3F) << 8) | *(mCurrentPosition + 1));
if (offset > mLookBehindMax)
if (offset >= mLookBehindMax)
{
// Potential infinite recursion.
mIsValid = false;
Expand Down
6 changes: 3 additions & 3 deletions src/lib/dnssd/minimal_mdns/core/tests/TestQName.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ void InvalidReferencing(nlTestSuite * inSuite, void * inContext)

{
// Infinite recursion
static const uint8_t kData[] = "\03test\xc0\x00";
static const uint8_t kData[] = "\04test\xc0\x00";
SerializedQNameIterator it = AsSerializedQName(kData);

NL_TEST_ASSERT(inSuite, it.Next());
Expand All @@ -146,7 +146,7 @@ void InvalidReferencing(nlTestSuite * inSuite, void * inContext)

{
// Infinite recursion by referencing own element (inside the stream)
static const uint8_t kData[] = "\03test\xc0\x05";
static const uint8_t kData[] = "\04test\xc0\x05";
SerializedQNameIterator it = AsSerializedQName(kData);

NL_TEST_ASSERT(inSuite, it.Next());
Expand All @@ -165,7 +165,7 @@ void InvalidReferencing(nlTestSuite * inSuite, void * inContext)

{
// Reference that goes forwad instead of backward
static const uint8_t kData[] = "\03test\xc0\x07";
static const uint8_t kData[] = "\04test\xc0\x07";
SerializedQNameIterator it = AsSerializedQName(kData);

NL_TEST_ASSERT(inSuite, it.Next());
Expand Down
Loading