From 3d70aa9b9209a0aac80aef5c88d28dd3a74fc66a Mon Sep 17 00:00:00 2001 From: Nick Banks Date: Sat, 20 Apr 2024 20:10:38 -0400 Subject: [PATCH] Fix a Few CodeQL Warnings (#4250) --- src/core/recv_buffer.c | 2 +- src/core/stream_send.c | 2 +- src/perf/lib/SecNetPerfMain.cpp | 4 ++-- src/platform/unittest/CryptTest.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/core/recv_buffer.c b/src/core/recv_buffer.c index 8f9e844f1d..4ed8e12c10 100644 --- a/src/core/recv_buffer.c +++ b/src/core/recv_buffer.c @@ -684,7 +684,7 @@ QuicRecvBufferRead( Link); BOOLEAN IsFirstChunk = TRUE; uint32_t ChunkLength = RecvBuffer->ReadLength; - while (ChunkLength <= ReadOffset) { + while ((uint64_t)ChunkLength <= ReadOffset) { CXPLAT_DBG_ASSERT(ChunkLength); CXPLAT_DBG_ASSERT(Chunk->ExternalReference); CXPLAT_DBG_ASSERT(Chunk->Link.Flink != &RecvBuffer->Chunks); diff --git a/src/core/stream_send.c b/src/core/stream_send.c index 2ce3864417..2cfddebd0a 100644 --- a/src/core/stream_send.c +++ b/src/core/stream_send.c @@ -720,7 +720,7 @@ QuicStreamCopyFromSendRequests( // uint32_t CurIndex = 0; // Index of the current buffer. uint64_t CurOffset = Offset - Req->StreamOffset; // Offset in the current buffer. - while (CurOffset >= Req->Buffers[CurIndex].Length) { + while (CurOffset >= (uint64_t)Req->Buffers[CurIndex].Length) { CurOffset -= Req->Buffers[CurIndex++].Length; } diff --git a/src/perf/lib/SecNetPerfMain.cpp b/src/perf/lib/SecNetPerfMain.cpp index 96a02192e3..49a29d2940 100644 --- a/src/perf/lib/SecNetPerfMain.cpp +++ b/src/perf/lib/SecNetPerfMain.cpp @@ -155,8 +155,8 @@ QuicMainStart( if ((CpuStr = GetValue(argc, argv, "cpu")) != nullptr) { SetConfig = true; if (strtol(CpuStr, nullptr, 10) == -1) { - for (uint16_t i = 0; i < CxPlatProcCount() && Config->ProcessorCount < 256; ++i) { - Config->ProcessorList[Config->ProcessorCount++] = i; + for (uint32_t i = 0; i < CxPlatProcCount() && Config->ProcessorCount < 256; ++i) { + Config->ProcessorList[Config->ProcessorCount++] = (uint16_t)i; } } else { do { diff --git a/src/platform/unittest/CryptTest.cpp b/src/platform/unittest/CryptTest.cpp index 619a90d40a..1dbc75deb3 100644 --- a/src/platform/unittest/CryptTest.cpp +++ b/src/platform/unittest/CryptTest.cpp @@ -327,7 +327,7 @@ struct CryptTest : public ::testing::TestWithParam ASSERT_EQ(0, memcmp(HpMask, ExpectedHpMask.Data, ExpectedHpMask.Length)); PacketBuffer[0] ^= HpMask[0] & 0x1F; - for (uint8_t i = 1; i < ExpectedHeader.Length; ++i) { + for (uint16_t i = 1; i < ExpectedHeader.Length; ++i) { PacketBuffer[i] ^= HpMask[i]; } ASSERT_EQ(0, memcmp(PacketBuffer, ExpectedHeader.Data, ExpectedHeader.Length));