Skip to content

Commit ec046ee

Browse files
Copilotsaikat107
andauthored
Fix copy-paste bugs in settings.c for TlsServerMaxSendBuffer (#5823)
Three copy-paste bugs in `src/core/settings.c` caused `TlsServerMaxSendBuffer` to never be properly initialized with its default value or propagated during settings merge/copy. A full scan of the file confirmed no further instances of this pattern remain. ## Description - **Default initialization** (`QuicSettingsSetDefault`): Second `if` block was checking/assigning `TlsClientMaxSendBuffer` with `QUIC_MAX_TLS_SERVER_SEND_BUFFER` — corrected to check and assign `TlsServerMaxSendBuffer`. - **Settings copy/merge** (`QuicSettingsCopy`): Two duplicate blocks (exact copies of the `TlsClientMaxSendBuffer` block) were silently no-ops for `TlsServerMaxSendBuffer` — both corrected to operate on `TlsServerMaxSendBuffer` (one at the originally reported location ~line 530, and one additional instance found at line 249). - **Full scan**: All three functions that follow this pattern (`QuicSettingsSetDefault`, `QuicSettingsCopy`, `QuicSettingsMerge`) were audited and confirmed to have no remaining instances of this bug. ## Testing No existing tests cover these specific fields directly. The bugs were logic errors (dead/duplicate code paths), not behavioral regressions, so no new tests are added. ## Documentation No documentation impact. <!-- START COPILOT ORIGINAL PROMPT --> <details> <summary>Original prompt</summary> > > ---- > > *This section details on the original issue you should resolve* > > <issue_title>Duplicate code in `src/core/settings.c`</issue_title> > <issue_description> > ## Source > 1. In `src/core/settings.c`, [Lines 530-533](https://github.com/microsoft/msquic/blob/main/src/core/settings.c#L530-L533) and [Lines 534-537](https://github.com/microsoft/msquic/blob/main/src/core/settings.c#L534-L537) are exactly the same. > 2. [Lines 90-92](https://github.com/microsoft/msquic/blob/main/src/core/settings.c#L90-L92) and [Lines 93-95](https://github.com/microsoft/msquic/blob/main/src/core/settings.c#L93-L95) are almost the same, except in the line 95 `Settings->TlsClientMaxSendBuffer` is set to `QUIC_MAX_TLS_SERVER_SEND_BUFFER` (which was previously set to `QUIC_MAX_TLS_CLIENT_SEND_BUFFER`. > > </issue_description> > > <agent_instructions>Fix the issue, remove duplicate code</agent_instructions> > > ## Comments on the Issue (you are @copilot in this section) > > <comments> > </comments> > </details> <!-- START COPILOT CODING AGENT SUFFIX --> - Fixes #5822 <!-- START COPILOT CODING AGENT TIPS --> --- 🔒 GitHub Advanced Security automatically protects Copilot coding agent pull requests. You can protect all pull requests by enabling Advanced Security for your repositories. [Learn more about Advanced Security.](https://gh.io/cca-advanced-security) --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: saikat107 <2145576+saikat107@users.noreply.github.com>
1 parent d87376c commit ec046ee

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed

src/core/settings.c

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -90,8 +90,8 @@ QuicSettingsSetDefault(
9090
if (!Settings->IsSet.TlsClientMaxSendBuffer) {
9191
Settings->TlsClientMaxSendBuffer = QUIC_MAX_TLS_CLIENT_SEND_BUFFER;
9292
}
93-
if (!Settings->IsSet.TlsClientMaxSendBuffer) {
94-
Settings->TlsClientMaxSendBuffer = QUIC_MAX_TLS_SERVER_SEND_BUFFER;
93+
if (!Settings->IsSet.TlsServerMaxSendBuffer) {
94+
Settings->TlsServerMaxSendBuffer = QUIC_MAX_TLS_SERVER_SEND_BUFFER;
9595
}
9696
if (!Settings->IsSet.StreamRecvWindowDefault) {
9797
Settings->StreamRecvWindowDefault = QUIC_DEFAULT_STREAM_FC_WINDOW_SIZE;
@@ -246,8 +246,8 @@ QuicSettingsCopy(
246246
if (!Destination->IsSet.TlsClientMaxSendBuffer) {
247247
Destination->TlsClientMaxSendBuffer = Source->TlsClientMaxSendBuffer;
248248
}
249-
if (!Destination->IsSet.TlsClientMaxSendBuffer) {
250-
Destination->TlsClientMaxSendBuffer = Source->TlsClientMaxSendBuffer;
249+
if (!Destination->IsSet.TlsServerMaxSendBuffer) {
250+
Destination->TlsServerMaxSendBuffer = Source->TlsServerMaxSendBuffer;
251251
}
252252
if (!Destination->IsSet.StreamRecvWindowDefault) {
253253
Destination->StreamRecvWindowDefault = Source->StreamRecvWindowDefault;
@@ -531,9 +531,9 @@ QuicSettingApply(
531531
Destination->TlsClientMaxSendBuffer = Source->TlsClientMaxSendBuffer;
532532
Destination->IsSet.TlsClientMaxSendBuffer = TRUE;
533533
}
534-
if (Source->IsSet.TlsClientMaxSendBuffer && (!Destination->IsSet.TlsClientMaxSendBuffer || OverWrite)) {
535-
Destination->TlsClientMaxSendBuffer = Source->TlsClientMaxSendBuffer;
536-
Destination->IsSet.TlsClientMaxSendBuffer = TRUE;
534+
if (Source->IsSet.TlsServerMaxSendBuffer && (!Destination->IsSet.TlsServerMaxSendBuffer || OverWrite)) {
535+
Destination->TlsServerMaxSendBuffer = Source->TlsServerMaxSendBuffer;
536+
Destination->IsSet.TlsServerMaxSendBuffer = TRUE;
537537
}
538538
if (Source->IsSet.StreamRecvWindowDefault && (!Destination->IsSet.StreamRecvWindowDefault || OverWrite)) {
539539
if (Source->StreamRecvWindowDefault == 0 || (Source->StreamRecvWindowDefault & (Source->StreamRecvWindowDefault - 1)) != 0) {

0 commit comments

Comments
 (0)