Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2022-07-13 11:34:18 +0300
committerDavid Crocker <dcrocker@eschertech.com>2022-07-13 11:34:18 +0300
commitc6f0aeb4fc1586712b81b094317b8a9eec9e8ede (patch)
tree7064797202e28c4997c238b32728ec6896ff2db6
parentc358c80be54ad00bd2d0cd4de06a2b05b479dc8d (diff)
Fixed array bounds overflow in modified code
-rw-r--r--src/Networking/LwipEthernet/LwipEthernetInterface.cpp4
-rw-r--r--src/Networking/LwipEthernet/LwipEthernetInterface.h2
-rw-r--r--src/Networking/NetworkDefs.h1
3 files changed, 3 insertions, 4 deletions
diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
index 63268c44..58c9da14 100644
--- a/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
+++ b/src/Networking/LwipEthernet/LwipEthernetInterface.cpp
@@ -146,9 +146,9 @@ void LwipEthernetInterface::Init() noexcept
lwipMutex.Create("LwipCore");
// Clear the PCBs
- for (size_t i = 0; i < NumTcpPorts; ++i)
+ for (tcp_pcb*& pcb : listeningPcbs)
{
- listeningPcbs[i] = nullptr;
+ pcb = nullptr;
}
macAddress = platform.GetDefaultMacAddress();
diff --git a/src/Networking/LwipEthernet/LwipEthernetInterface.h b/src/Networking/LwipEthernet/LwipEthernetInterface.h
index 01fa0f03..12c2bc08 100644
--- a/src/Networking/LwipEthernet/LwipEthernetInterface.h
+++ b/src/Networking/LwipEthernet/LwipEthernetInterface.h
@@ -87,7 +87,7 @@ private:
TcpPort portNumbers[NumProtocols]; // port number used for each protocol
bool protocolEnabled[NumProtocols]; // whether each protocol is enabled
bool closeDataPort;
- tcp_pcb *listeningPcbs[NumTcpPorts];
+ tcp_pcb *listeningPcbs[NumProtocols + 1];
bool activated;
bool initialised;
diff --git a/src/Networking/NetworkDefs.h b/src/Networking/NetworkDefs.h
index 2ef74aa4..d1f17b9e 100644
--- a/src/Networking/NetworkDefs.h
+++ b/src/Networking/NetworkDefs.h
@@ -46,7 +46,6 @@ constexpr size_t NumProtocols = NumTcpProtocols; // number of network protocols
constexpr NetworkProtocol HttpProtocol = 0, FtpProtocol = 1, TelnetProtocol = 2, MulticastDiscoveryProtocol = 3, FtpDataProtocol = 3, MdnsProtocol = 4, AnyProtocol = 255;
-constexpr size_t NumTcpPorts = NumTcpProtocols + 1;
constexpr TcpPort DefaultHttpPort = 80;
constexpr TcpPort DefaultFtpPort = 21;
constexpr TcpPort DefaultTelnetPort = 23;