Skip to content

Commit 8f14a8e

Browse files
authored
build: cache patches (#352)
1 parent d603b95 commit 8f14a8e

6 files changed

+125
-2
lines changed

get-msquic.sh

+9-2
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@ do_patch()
1010
{
1111
patch_source="$1"
1212
patch_file="${patch_dir}/$(basename ${patch_source})"
13-
curl -f -L -o "${patch_file}" "$patch_source"
13+
14+
if [ -f "${patch_file}" ]; then
15+
echo "Patch ${patch_file} already exists, skipping download"
16+
else
17+
curl -f -L -o "${patch_file}" "$patch_source"
18+
fi
1419
if patch -p1 -f --dry-run -s < "${patch_file}" 2>/dev/null; then
1520
patch -p1 < "${patch_file}"
1621
else
@@ -42,7 +47,9 @@ patch_2_3_8()
4247
local patch_2="https://github.com/microsoft/msquic/commit/e0201eb4e007e7524aef007be67f2281f949f102.patch"
4348
local patch_3="https://github.com/microsoft/msquic/commit/b16a14a72e8c74407ee4a079a1f57efe0246f739.patch"
4449
local patch_4="https://github.com/microsoft/msquic/pull/4717/commits/9261dacc1dd9a67f6fa8d5fbe663082508b4c605.patch"
45-
mkdir -p "$patch_dir"
50+
if [ ! -d "$patch_dir" ]; then
51+
ln -s ../msquic_patches "$patch_dir"
52+
fi
4653
echo "Patching Msquic 2.3.8"
4754
for p in patch_1 patch_2 patch_3 patch_4; do
4855
do_patch "${!p}"
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
From 12edf3725475d4a99e5598df3289bace47b8f56e Mon Sep 17 00:00:00 2001
2+
From: Nick Banks <[email protected]>
3+
Date: Mon, 18 Mar 2024 12:34:17 -0400
4+
Subject: [PATCH] Fix Posix QuicAddrToString (#4197)
5+
6+
---
7+
src/inc/msquic_posix.h | 7 +++++--
8+
1 file changed, 5 insertions(+), 2 deletions(-)
9+
10+
diff --git a/src/inc/msquic_posix.h b/src/inc/msquic_posix.h
11+
index 612d67afb4..27393e1233 100644
12+
--- a/src/inc/msquic_posix.h
13+
+++ b/src/inc/msquic_posix.h
14+
@@ -489,16 +489,18 @@ QuicAddrToString(
15+
_Out_ QUIC_ADDR_STR* AddrStr
16+
)
17+
{
18+
+ size_t AvailSpace = sizeof(AddrStr->Address);
19+
char* Address = AddrStr->Address;
20+
if (Addr->Ip.sa_family == QUIC_ADDRESS_FAMILY_INET6 && Addr->Ipv6.sin6_port != 0) {
21+
Address[0] = '[';
22+
Address++;
23+
+ AvailSpace--;
24+
}
25+
if (inet_ntop(
26+
Addr->Ip.sa_family == QUIC_ADDRESS_FAMILY_INET ? AF_INET : AF_INET6,
27+
Addr->Ip.sa_family == QUIC_ADDRESS_FAMILY_INET ? (void*)&Addr->Ipv4.sin_addr : (void*)&Addr->Ipv6.sin6_addr,
28+
Address,
29+
- sizeof(QUIC_ADDR_STR)) == NULL) {
30+
+ AvailSpace) == NULL) {
31+
return FALSE;
32+
}
33+
if (Addr->Ipv4.sin_port != 0) {
34+
@@ -507,7 +509,8 @@ QuicAddrToString(
35+
Address[0] = ']';
36+
Address++;
37+
}
38+
- snprintf(Address, 64, ":%hu", ntohs(Addr->Ipv4.sin_port));
39+
+ AvailSpace = sizeof(AddrStr->Address) - (Address - AddrStr->Address);
40+
+ snprintf(Address, AvailSpace, ":%hu", ntohs(Addr->Ipv4.sin_port));
41+
}
42+
return TRUE;
43+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
From 9261dacc1dd9a67f6fa8d5fbe663082508b4c605 Mon Sep 17 00:00:00 2001
2+
From: William Yang <[email protected]>
3+
Date: Thu, 19 Dec 2024 13:36:38 +0100
4+
Subject: [PATCH] fix(epoll): buffer overflow when GSO off
5+
6+
---
7+
src/platform/datapath_epoll.c | 3 ++-
8+
1 file changed, 2 insertions(+), 1 deletion(-)
9+
10+
diff --git a/src/platform/datapath_epoll.c b/src/platform/datapath_epoll.c
11+
index 92ad4a34aa..9176427831 100644
12+
--- a/src/platform/datapath_epoll.c
13+
+++ b/src/platform/datapath_epoll.c
14+
@@ -2154,7 +2154,8 @@ CxPlatSendDataFinalizeSendBuffer(
15+
struct iovec* IoVec = &SendData->Iovs[SendData->BufferCount - 1];
16+
IoVec->iov_base = SendData->ClientBuffer.Buffer;
17+
IoVec->iov_len = SendData->ClientBuffer.Length;
18+
- if (SendData->TotalSize + SendData->SegmentSize > sizeof(SendData->Buffer) ||
19+
+ if (SendData->SegmentSize == 0 ||
20+
+ SendData->TotalSize + SendData->SegmentSize > sizeof(SendData->Buffer) ||
21+
SendData->BufferCount == SendData->SocketContext->DatapathPartition->Datapath->SendIoVecCount) {
22+
SendData->ClientBuffer.Buffer = NULL;
23+
} else {

msquic_patches/README.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Cache dir for Msquic Patches
2+
3+
For patch sources see [get-msquic.sh](../get-msquic.sh).
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
From b16a14a72e8c74407ee4a079a1f57efe0246f739 Mon Sep 17 00:00:00 2001
2+
From: William Yang <[email protected]>
3+
Date: Thu, 16 May 2024 10:21:54 +0200
4+
Subject: [PATCH] fix: buffer overflow in quic_trace
5+
6+
---
7+
src/generated/stdout/quic_trace.c | 2 +-
8+
1 file changed, 1 insertion(+), 1 deletion(-)
9+
10+
diff --git a/src/generated/stdout/quic_trace.c b/src/generated/stdout/quic_trace.c
11+
index d550d20101..8c79b270bf 100644
12+
--- a/src/generated/stdout/quic_trace.c
13+
+++ b/src/generated/stdout/quic_trace.c
14+
@@ -49,7 +49,7 @@ char * casted_clog_bytearray(const uint8_t * const data,
15+
param->str = CXPLAT_ALLOC_PAGED(len * 2 + 1, QUIC_POOL_TMP_ALLOC);
16+
if (param->str) {
17+
EncodeHexBuffer((uint8_t *)data, (uint8_t)len, param->str);
18+
- param->str[len * 2 + 1] = 0;
19+
+ param->str[len * 2] = 0;
20+
}
21+
22+
} else {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
From e0201eb4e007e7524aef007be67f2281f949f102 Mon Sep 17 00:00:00 2001
2+
From: Nick Banks <[email protected]>
3+
Date: Wed, 25 Sep 2024 14:16:29 -0400
4+
Subject: [PATCH] Zero out memory from PacketNumber in
5+
QuicBindingPreprocessPacket (#4560)
6+
7+
---
8+
src/core/binding.c | 4 +++-
9+
1 file changed, 3 insertions(+), 1 deletion(-)
10+
11+
diff --git a/src/core/binding.c b/src/core/binding.c
12+
index 68d538f8fd..b0296a0ca5 100644
13+
--- a/src/core/binding.c
14+
+++ b/src/core/binding.c
15+
@@ -1134,7 +1134,9 @@ QuicBindingPreprocessPacket(
16+
_Out_ BOOLEAN* ReleaseDatagram
17+
)
18+
{
19+
- CxPlatZeroMemory(&Packet->PacketNumber, sizeof(QUIC_RX_PACKET) - sizeof(uint64_t));
20+
+ CxPlatZeroMemory( // Zero out everything from PacketNumber forward
21+
+ &Packet->PacketNumber,
22+
+ sizeof(QUIC_RX_PACKET) - offsetof(QUIC_RX_PACKET, PacketNumber));
23+
Packet->AvailBuffer = Packet->Buffer;
24+
Packet->AvailBufferLength = Packet->BufferLength;
25+

0 commit comments

Comments
 (0)