Skip to content

Commit f3dfbce

Browse files
committed
fix some bugs in tunneling support detected by the usage of esp32 (heap corruption)
1 parent df4ce55 commit f3dfbce

4 files changed

+6
-4
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ See the examples for basic usage options
3030
- increase device object api version to 2 (invalidation of knx flash data stored by older versions)
3131
- add #pragma once to Arduino plattform to allow derived plattforms
3232
- change esp32 plattform to use KNX_NETIF
33+
- fix out-of-boundary write and dereferenced nullpointer access in tunneling support
3334

3435
### V2.1.1 - 2024-09-16
3536
- fix minor bug in TP-Uart Driver (RX queue out of boundary)

src/knx/ip_data_link_layer.cpp

+2-2
Original file line numberDiff line numberDiff line change
@@ -766,8 +766,8 @@ void IpDataLinkLayer::loopHandleConnectRequest(uint8_t* buffer, uint16_t length,
766766
tun = nullptr;
767767
break;
768768
}
769-
770-
tun->IndividualAddress = tunPa;
769+
if(tun)
770+
tun->IndividualAddress = tunPa;
771771

772772
}
773773

src/knx/ip_data_link_layer.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ class IpDataLinkLayer : public DataLinkLayer
5454
DataLinkLayerCallbacks* _dllcb;
5555
#ifdef KNX_TUNNELING
5656
KnxIpTunnelConnection tunnels[KNX_TUNNELING];
57-
uint8_t _lastChannelId = 1;
57+
uint8_t _lastChannelId = 0;
5858
#endif
5959
};
6060
#endif

src/knx/knx_ip_connect_response.cpp

+2-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@ KnxIpConnectResponse::KnxIpConnectResponse(IpParameterObject& parameters, uint16
1717

1818
_crd.length((type == 4) ? 4 : 2); //TunnelConnectionResponse length = 4; ConfigConnectionResponse length = 2;
1919
_crd.type(type);
20-
_crd.address(address);
20+
if(type == 4) // only fill address when it is a TunnelConnectionResponse
21+
_crd.address(address);
2122
}
2223

2324
KnxIpConnectResponse::KnxIpConnectResponse(uint8_t channel, uint8_t errorCode)

0 commit comments

Comments
 (0)