Skip to content

Commit

Permalink
Restrict MaxOperationsPerDrain to Greater Than Zero
Browse files Browse the repository at this point in the history
  • Loading branch information
nibanks authored Dec 12, 2024
1 parent 21e5b41 commit c4b51ce
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/core/settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,9 @@ QuicSettingApply(
Destination->IsSet.DatagramReceiveEnabled = TRUE;
}
if (Source->IsSet.MaxOperationsPerDrain && (!Destination->IsSet.MaxOperationsPerDrain || OverWrite)) {
if (Source->MaxOperationsPerDrain == 0) {
return FALSE;
}
Destination->MaxOperationsPerDrain = Source->MaxOperationsPerDrain;
Destination->IsSet.MaxOperationsPerDrain = TRUE;
}
Expand Down Expand Up @@ -795,7 +798,7 @@ QuicSettingsLoad(
QUIC_SETTING_MAX_OPERATIONS_PER_DRAIN,
(uint8_t*)&Value,
&ValueLen);
if (Value <= UINT8_MAX) {
if (Value > 0 && Value <= UINT8_MAX) {
Settings->MaxOperationsPerDrain = (uint8_t)Value;
}
}
Expand Down
26 changes: 26 additions & 0 deletions src/test/lib/ApiTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2090,6 +2090,32 @@ void SettingApplyTests(HQUIC Handle, uint32_t Param, bool AllowMtuEcnChanges = t
sizeof(QUIC_SETTINGS),
&Settings));
}

//
// MaxOperationsPerDrain
//
{
QUIC_SETTINGS Settings{0};
Settings.IsSet.MaxOperationsPerDrain = TRUE;

Settings.MaxOperationsPerDrain = 0; // Not allowed
TEST_QUIC_STATUS(
QUIC_STATUS_INVALID_PARAMETER,
MsQuic->SetParam(
Handle,
Param,
sizeof(QUIC_SETTINGS),
&Settings));

Settings.MaxOperationsPerDrain = 255; // Max allowed
TEST_QUIC_STATUS(
QUIC_STATUS_SUCCESS,
MsQuic->SetParam(
Handle,
Param,
sizeof(QUIC_SETTINGS),
&Settings));
}
}

void QuicTestStatefulGlobalSetParam()
Expand Down

0 comments on commit c4b51ce

Please sign in to comment.