Skip to content

Commit

Permalink
Validate buffer and address in local address add/remove functions
Browse files Browse the repository at this point in the history
  • Loading branch information
masa-koz committed Jan 10, 2025
1 parent aaf479d commit 01f7e15
Showing 1 changed file with 6 additions and 18 deletions.
24 changes: 6 additions & 18 deletions src/core/connection.c
Original file line number Diff line number Diff line change
Expand Up @@ -7107,37 +7107,25 @@ QuicConnParamSet(

case QUIC_PARAM_CONN_ADD_LOCAL_ADDRESS: {

if (BufferLength != sizeof(QUIC_ADDR)) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}

QUIC_ADDR* LocalAddress = (QUIC_ADDR*)Buffer;

if (!QuicAddrIsValid(LocalAddress)) {
if (BufferLength != sizeof(QUIC_ADDR) || Buffer == NULL ||
!QuicAddrIsValid((QUIC_ADDR*)Buffer)) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}

Status = QuicConnAddLocalAddress(Connection, LocalAddress);
Status = QuicConnAddLocalAddress(Connection, (QUIC_ADDR*)Buffer);
break;
}

case QUIC_PARAM_CONN_REMOVE_LOCAL_ADDRESS: {

if (BufferLength != sizeof(QUIC_ADDR)) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}

QUIC_ADDR* LocalAddress = (QUIC_ADDR*)Buffer;

if (!QuicAddrIsValid(LocalAddress)) {
if (BufferLength != sizeof(QUIC_ADDR) || Buffer == NULL ||
!QuicAddrIsValid((QUIC_ADDR*)Buffer)) {
Status = QUIC_STATUS_INVALID_PARAMETER;
break;
}

Status = QuicConnRemoveLocalAddress(Connection, LocalAddress);
Status = QuicConnRemoveLocalAddress(Connection, (QUIC_ADDR*)Buffer);
break;
}

Expand Down

0 comments on commit 01f7e15

Please sign in to comment.