From 62c210c65ddb029709683b1ba79d661e795052f0 Mon Sep 17 00:00:00 2001 From: Llorenc Capella Date: Wed, 10 May 2023 14:40:51 +0200 Subject: [PATCH 1/2] MAC Address function added to the InternetHost --- .../Environment/Linux/InternetHost.cpp | 92 +++-- .../FileSystem/L1Portability/InternetHost.h | 373 +++++++++--------- .../L1Portability/InternetHostTest.cpp | 43 +- .../L1Portability/InternetHostTest.h | 2 + .../L1Portability/InternetHostGTest.cpp | 5 + 5 files changed, 305 insertions(+), 210 deletions(-) diff --git a/Source/Core/FileSystem/L1Portability/Environment/Linux/InternetHost.cpp b/Source/Core/FileSystem/L1Portability/Environment/Linux/InternetHost.cpp index b64fccfb3..81f908bc2 100644 --- a/Source/Core/FileSystem/L1Portability/Environment/Linux/InternetHost.cpp +++ b/Source/Core/FileSystem/L1Portability/Environment/Linux/InternetHost.cpp @@ -93,10 +93,10 @@ class LocalHostInfo { /*lint -e{1704} .Justification: The constructor is private because this is a singleton.*/ LocalHostInfo() : - localHostName(static_cast(NULL)), - ipAddress(static_cast(NULL)), - internetAddressInfoInitialised(false), - internalFastSem() { + localHostName(static_cast(NULL)), + ipAddress(static_cast(NULL)), + internetAddressInfoInitialised(false), + internalFastSem() { Init(); } @@ -112,7 +112,7 @@ class LocalHostInfo { char8 hostname[128]; int32 ret = gethostname(&hostname[0], static_cast(128u)); - struct hostent *h = static_cast(NULL); + struct hostent *h = NULL_PTR(struct hostent *); if (ret == 0) { h = gethostbyname(&hostname[0]); } @@ -120,13 +120,22 @@ class LocalHostInfo { localHostName = strdup(h->h_name); struct in_addr sin_addr; char8* addr = h->h_addr_list[0]; - if (addr != static_cast(NULL)) { - sin_addr.s_addr = *(reinterpret_cast(addr)); - - // Convert the ip number in a dot notation string - ipAddress = strdup(inet_ntoa(sin_addr)); - internetAddressInfoInitialised = true; - internalFastSem.FastUnLock(); + if (addr != NULL_PTR(char8*)) { + int32 allowedAddresslength = static_cast(sizeof(int32)); + if(h->h_length != allowedAddresslength) { + REPORT_ERROR_STATIC_0(ErrorManagement::FatalError, "LocalHostInfo: Address area not expected. Allowed address length 4"); + } + else { + //lint -e{826} Suspicious pointer-to-pointer conversion (area too small). if check the aread of the address + //lint -e{927} allowedAddresslength + uint32 * auxInt32Pointer = reinterpret_cast(addr); + sin_addr.s_addr = *auxInt32Pointer; + + // Convert the ip number in a dot notation string + ipAddress = strdup(inet_ntoa(sin_addr)); + internetAddressInfoInitialised = true; + internalFastSem.FastUnLock(); + } } else { REPORT_ERROR_STATIC_0(ErrorManagement::FatalError, "LocalHostInfo: Failed local address initialization"); @@ -185,27 +194,56 @@ uint32 InternetHost::GetLocalAddressAsNumber() { } return ret; } +bool InternetHost::GetMACAddress(const char8 *const interfaceName, + uint8 *const mac) { + + struct ifreq s; + bool ret = MemoryOperationsHelper::Set(reinterpret_cast(&s), static_cast(0), static_cast(sizeof(s))); + //lint -e{641} Converting enum '__socket_type' to 'int. Definition and function outside the MARTe library. SOCK_DGRAM is a int type. + int32 fd = socket(PF_INET, SOCK_DGRAM, IPPROTO_IP); + //strcpy(s.ifr_name, interfaceName); + if (ret) { + ret = MemoryOperationsHelper::Copy(reinterpret_cast(s.ifr_name), interfaceName, static_cast(IFNAMSIZ - 1)); + } + if (ret) { + ret = 0 == ioctl(fd, static_cast(SIOCGIFHWADDR), &s); + } + if (ret) { + int32 i; + for (i = 0; i < 6; ++i) { + uint8 auxChar = static_cast(s.ifr_addr.sa_data[i]); + mac[i] = auxChar; + } + } + return ret; +} -InternetAddress InternetHost::ConvertInterfaceNameToInterfaceAddressNumber(const char8* const interfaceName) { +InternetAddress InternetHost::ConvertInterfaceNameToInterfaceAddressNumber(const char8 *const interfaceName) { int32 fd; struct ifreq ifr; + bool ret = MemoryOperationsHelper::Set(&ifr, static_cast(0), static_cast(sizeof(ifr))); InternetAddress retVal = 0u; //lint -e{641} Converting enum '__socket_type' to 'int. Definition and function outside the MARTe library. SOCK_DGRAM is a int type. fd = socket(AF_INET, SOCK_DGRAM, 0); //Type of address to retrieve - IPv4 IP address ifr.ifr_addr.sa_family = static_cast(AF_INET); //Copy the interface name in the ifreq structure - strncpy(static_cast(ifr.ifr_name), interfaceName, static_cast(IFNAMSIZ - 1)); - if (ioctl(fd, static_cast(SIOCGIFADDR), &ifr) != -1) { - in_addr addr = (reinterpret_cast(&ifr.ifr_addr))->sin_addr; - retVal = addr.s_addr; + if (ret) { + ret = MemoryOperationsHelper::Copy(reinterpret_cast(ifr.ifr_name), interfaceName, static_cast(IFNAMSIZ - 1)); + } + if (ret) { + if (ioctl(fd, static_cast(SIOCGIFADDR), &ifr) != -1) { + //lint -e{740} Unusual pointer cast (incompatible indirect types) [MISRA C++ Rule 5-2-6], [MISRA C++ Rule 5-2-7] + in_addr addr = (reinterpret_cast(&ifr.ifr_addr))->sin_addr; + retVal = addr.s_addr; + } } close(fd); return retVal; } -StreamString InternetHost::ConvertInterfaceNameToInterfaceAddress(const char8* const interfaceName) { +StreamString InternetHost::ConvertInterfaceNameToInterfaceAddress(const char8 *const interfaceName) { in_addr aux; aux.s_addr = ConvertInterfaceNameToInterfaceAddressNumber(interfaceName); StreamString dotName(inet_ntoa(aux)); @@ -213,7 +251,7 @@ StreamString InternetHost::ConvertInterfaceNameToInterfaceAddress(const char8* c } InternetHost::InternetHost(const uint16 port, - const char8 * const addr) { + const char8 *const addr) { mreq.imr_interface.s_addr = htonl(static_cast(0x00000000)); //INADDR_ANY mreq.imr_multiaddr.s_addr = static_cast(0); address.sin_family = static_cast(AF_INET); @@ -242,7 +280,7 @@ void InternetHost::SetPort(const uint16 port) { address.sin_port = htons(port); } -bool InternetHost::SetAddress(const char8 * const addr) { +bool InternetHost::SetAddress(const char8 *const addr) { /*lint -e{1924} [MISRA C++ Rule 5-2-4]. Justification: The C-style cast is made by the operating system API.*/ address.sin_addr.s_addr = INADDR_ANY; bool ret = (addr != NULL); @@ -271,8 +309,14 @@ bool InternetHost::SetAddressByHostName(const char8 *hostName) { struct hostent *h = gethostbyname(hostName); if (h != NULL) { - address.sin_addr.s_addr = *(reinterpret_cast(h->h_addr_list[0])); - ret = true; + if(h->h_length == 4){ + //lint -e{826} Suspicious pointer-to-pointer conversion (area too small). If ensure same size. + //lint -e{927} cast from pointer to pointer [MISRA C++ Rule 5-2-7]. Size are guaranteed. + address.sin_addr.s_addr = *(reinterpret_cast(h->h_addr_list[0])); + ret = true; + }else{ + ret = false; + } } else { REPORT_ERROR_STATIC_0(ErrorManagement::OSError, "InternetHost: Failed gethostbyname()"); @@ -289,11 +333,11 @@ bool InternetHost::SetLocalAddress() { return SetAddressByHostName(static_cast(NULL)); } -void InternetHost::SetMulticastGroup(const char8 * const addr) { +void InternetHost::SetMulticastGroup(const char8 *const addr) { mreq.imr_multiaddr.s_addr = inet_addr(const_cast(addr)); } -void InternetHost::SetMulticastInterfaceAddress(const char8 * const addr) { +void InternetHost::SetMulticastInterfaceAddress(const char8 *const addr) { mreq.imr_interface.s_addr = inet_addr(const_cast(addr)); } diff --git a/Source/Core/FileSystem/L1Portability/InternetHost.h b/Source/Core/FileSystem/L1Portability/InternetHost.h index 81712457b..de97eb5ac 100644 --- a/Source/Core/FileSystem/L1Portability/InternetHost.h +++ b/Source/Core/FileSystem/L1Portability/InternetHost.h @@ -41,190 +41,197 @@ namespace MARTe { +/** + * @brief Class which describes the configuration of an internet host, like + * its IPv4 address, port and host name. + */ +class DLL_API InternetHost { + +public: + + /** + * @brief Default constructor. + * @param[in] port the port number. + * @param[in] addr the IPv4 address in the format x.x.x.x. + * @pre + * The address must be in the IPv4 format (3-digits numbers in [0-255] separated by dots). + * A wrong format => GetAddress()==0.0.0.0 + * @post + * GetPort() == port\n + * GetAddress() == addr + */ + InternetHost(const uint16 port = 0u, + const char8 *const addr = static_cast(NULL_PTR(char8*))); + + /** + * @brief Returns the port number. + * @return the port number. + */ + uint16 GetPort() const; + + /** + * @brief Returns the IP address in the IPv4 format. + * @return the IP address in the IPv4 format. + */ + StreamString GetAddress() const; + + /** + * @brief Returns the host name as a StreamString. + * @return the host name as a StreamString. In case of failure the returned StreamString is empty. + */ + StreamString GetHostName() const; + + /** + * @brief Returns the IP address as an integer number. + * @return the IP address as an integer number. + */ + uint32 GetAddressAsNumber() const; + + /** + * @brief Returns the host name of the machine where the library is being executed. + * @return the host name of the machine where the library is being executed. + */ + static const char8* GetLocalHostName(); + + /** + * @brief Returns the IP address of the machine where the library is being executed in the IPv4 format. + * @return the IP address of the machine where the library is being executed in the IPv4 format. + */ + static const char8* GetLocalAddress(); + + /** + * @brief Returns the IP address a.b.c.d as [a + 256*b + (256^2)*c + (256^3)*d] + * @return the IP address a.b.c.d as [a + 256*b + (256^2)*c + (256^3)*d] + */ + static uint32 GetLocalAddressAsNumber(); + + /** + * + */ + static bool GetMACAddress(const char8 *const interfaceName, + uint8 *const mac); + + /** + * @brief Translate interfaceName to internet address (i.e "enp0s25" --> 2676074688). + * @param[in] interfaceName interface name to be converted to internet address. + * @return the internet address number corresponding to interfaceName. If interfaceName does not exist it returns 0 + */ + static InternetAddress ConvertInterfaceNameToInterfaceAddressNumber(const char8 *const interfaceName); + + /** + * @brief Translate interfaceName to internet address (i.e "enp0s25" --> 192.168.129.44). + * @param[in] interfaceName interface name to be converted to internet address. + * @return the internet address number corresponding to interfaceName. If interfaceName does not exist it returns "0.0.0.0" + */ + static StreamString ConvertInterfaceNameToInterfaceAddress(const char8 *const interfaceName); + + /** + * @brief Sets the port number. + * @param[in] port is the desired port number. + * @post + * GetPort() == port + */ + void SetPort(const uint16 port); + + /** + * @brief Sets the IP address in the IPv4 format. + * @param[in] addr the desired IP number. + * @return false if the input format is incorrect. + * @pre + * addr must be in the IPv4 format (3-digits numbers in [0-255] separated by dots). + */ + bool SetAddress(const char8 *const addr); + /** - * @brief Class which describes the configuration of an internet host, like - * its IPv4 address, port and host name. - */ - class DLL_API InternetHost { - - public: - - /** - * @brief Default constructor. - * @param[in] port the port number. - * @param[in] addr the IPv4 address in the format x.x.x.x. - * @pre - * The address must be in the IPv4 format (3-digits numbers in [0-255] separated by dots). - * A wrong format => GetAddress()==0.0.0.0 - * @post - * GetPort() == port\n - * GetAddress() == addr - */ - InternetHost(const uint16 port=0u,const char8 * const addr=static_cast(NULL)); - - /** - * @brief Returns the port number. - * @return the port number. - */ - uint16 GetPort() const; - - /** - * @brief Returns the IP address in the IPv4 format. - * @return the IP address in the IPv4 format. - */ - StreamString GetAddress() const; - - /** - * @brief Returns the host name as a StreamString. - * @return the host name as a StreamString. In case of failure the returned StreamString is empty. - */ - StreamString GetHostName() const; - - /** - * @brief Returns the IP address as an integer number. - * @return the IP address as an integer number. - */ - uint32 GetAddressAsNumber() const; - - /** - * @brief Returns the host name of the machine where the library is being executed. - * @return the host name of the machine where the library is being executed. - */ - static const char8 *GetLocalHostName(); - - /** - * @brief Returns the IP address of the machine where the library is being executed in the IPv4 format. - * @return the IP address of the machine where the library is being executed in the IPv4 format. - */ - static const char8 *GetLocalAddress(); - - /** - * @brief Returns the IP address a.b.c.d as [a + 256*b + (256^2)*c + (256^3)*d] - * @return the IP address a.b.c.d as [a + 256*b + (256^2)*c + (256^3)*d] - */ - static uint32 GetLocalAddressAsNumber(); - - /** - * @brief Translate interfaceName to internet address (i.e "enp0s25" --> 2676074688). - * @param[in] interfaceName interface name to be converted to internet address. - * @return the internet address number corresponding to interfaceName. If interfaceName does not exist it returns 0 - */ - static InternetAddress ConvertInterfaceNameToInterfaceAddressNumber(const char8* const interfaceName); - - /** - * @brief Translate interfaceName to internet address (i.e "enp0s25" --> 192.168.129.44). - * @param[in] interfaceName interface name to be converted to internet address. - * @return the internet address number corresponding to interfaceName. If interfaceName does not exist it returns "0.0.0.0" - */ - static StreamString ConvertInterfaceNameToInterfaceAddress(const char8* const interfaceName); - - /** - * @brief Sets the port number. - * @param[in] port is the desired port number. - * @post - * GetPort() == port - */ - void SetPort(const uint16 port); - - /** - * @brief Sets the IP address in the IPv4 format. - * @param[in] addr the desired IP number. - * @return false if the input format is incorrect. - * @pre - * addr must be in the IPv4 format (3-digits numbers in [0-255] separated by dots). - */ - bool SetAddress(const char8 * const addr); - - /** - * @brief Sets the host name. - * @param[in] hostName the host name to be set. - * @return true if the host name is set correctly, false otherwise. - */ - bool SetAddressByHostName(const char8 * hostName); - - /** - * @brief Set the IP address a.b.c.d passing the equivalent input [a + 256*b + (256^2)*c + (256^3)*d]. - * @param[in] number is the IP address in unsigned int format. - */ - void SetAddressByNumber(const uint32 number); - - /** - * @brief Sets the address of the local hostname as "localhost" - * @return true if the local host name is set correctly, false otherwise. - * @post - * GetLocalHostName() == "localhost" - */ - bool SetLocalAddress(); - - /** - * @brief Set the IP address a.b.c.d belonging to a multicast group passing the equivalent input [a + 256*b + (256^2)*c + (256^3)*d]. - * @param[in] addr is the multicast IP address - */ - void SetMulticastGroup(const char8 * const addr); - - /** - * @brief The address of the interface to which to bind the multicast. - * @param[in] addr the network address of the interface where to bind the multicast. - */ - void SetMulticastInterfaceAddress(const char8 * const addr); - - /** - * @brief The address of the interface to which to bind the multicast. - * @param[in] interfaceAddr the interface address where to bind the multicast. addr = ConvertInterfaceNameToInterfaceAddress(interfaceName) - */ - void SetMulticastInterfaceAddress(const InternetAddress interfaceAddr); - - /** - * @brief Returns the multicast address of the bounding interface. - */ - StreamString GetMulticastInterfaceAddress() const; - - /** - * @brief Returns the Multicast address on a StreamString object - */ - StreamString GetMulticastGroup() const; - - /** - * @brief Returns access to the low-level handle. - * @return a pointer to the handle of this structure containing - * the InternetHostCore information. - * @remark The handle type definition is specific to the operating system. - */ - InternetHostCore *GetInternetHost(); - - /** - * @brief Returns access to the low-level handle. - * @return a pointer to the handle of this structure containing - * the InternetMulticastCore information. - * @remark The handle type definition is specific to the operating system. - */ - InternetMulticastCore *GetInternetMulticastHost(); - - /** - * @brief Gets the size in bytes of the handle. - * @return the size of InternetHostCore handle. - */ - uint32 Size() const; - - /** - * @brief Gets the size in bytes of the handle. - * @return the size of InternetMulticastCore handle. - */ - uint32 MulticastSize() const; - - private: - - /** - * The InternetHost handle. - */ - InternetHostCore address; - - /** - * The InternetMulticastCore handle. - */ - InternetMulticastCore mreq; - - }; + * @brief Sets the host name. + * @param[in] hostName the host name to be set. + * @return true if the host name is set correctly, false otherwise. + */ + bool SetAddressByHostName(const char8 *hostName); + + /** + * @brief Set the IP address a.b.c.d passing the equivalent input [a + 256*b + (256^2)*c + (256^3)*d]. + * @param[in] number is the IP address in unsigned int format. + */ + void SetAddressByNumber(const uint32 number); + + /** + * @brief Sets the address of the local hostname as "localhost" + * @return true if the local host name is set correctly, false otherwise. + * @post + * GetLocalHostName() == "localhost" + */ + bool SetLocalAddress(); + + /** + * @brief Set the IP address a.b.c.d belonging to a multicast group passing the equivalent input [a + 256*b + (256^2)*c + (256^3)*d]. + * @param[in] addr is the multicast IP address + */ + void SetMulticastGroup(const char8 *const addr); + + /** + * @brief The address of the interface to which to bind the multicast. + * @param[in] addr the network address of the interface where to bind the multicast. + */ + void SetMulticastInterfaceAddress(const char8 *const addr); + + /** + * @brief The address of the interface to which to bind the multicast. + * @param[in] interfaceAddr the interface address where to bind the multicast. addr = ConvertInterfaceNameToInterfaceAddress(interfaceName) + */ + void SetMulticastInterfaceAddress(const InternetAddress interfaceAddr); + + /** + * @brief Returns the multicast address of the bounding interface. + */ + StreamString GetMulticastInterfaceAddress() const; + + /** + * @brief Returns the Multicast address on a StreamString object + */ + StreamString GetMulticastGroup() const; + + /** + * @brief Returns access to the low-level handle. + * @return a pointer to the handle of this structure containing + * the InternetHostCore information. + * @remark The handle type definition is specific to the operating system. + */ + InternetHostCore* GetInternetHost(); + + /** + * @brief Returns access to the low-level handle. + * @return a pointer to the handle of this structure containing + * the InternetMulticastCore information. + * @remark The handle type definition is specific to the operating system. + */ + InternetMulticastCore* GetInternetMulticastHost(); + + /** + * @brief Gets the size in bytes of the handle. + * @return the size of InternetHostCore handle. + */ + uint32 Size() const; + + /** + * @brief Gets the size in bytes of the handle. + * @return the size of InternetMulticastCore handle. + */ + uint32 MulticastSize() const; + +private: + + /** + * The InternetHost handle. + */ + InternetHostCore address; + + /** + * The InternetMulticastCore handle. + */ + InternetMulticastCore mreq; + +}; } diff --git a/Test/Core/FileSystem/L1Portability/InternetHostTest.cpp b/Test/Core/FileSystem/L1Portability/InternetHostTest.cpp index 9ddd85de7..f44b84ea6 100644 --- a/Test/Core/FileSystem/L1Portability/InternetHostTest.cpp +++ b/Test/Core/FileSystem/L1Portability/InternetHostTest.cpp @@ -31,6 +31,8 @@ #include "StringHelper.h" #include "InternetHostTest.h" #include "stdio.h" +#include "MemoryOperationsHelper.h" +#include "AdvancedErrorManagement.h" //WARNING: These defines are used to allow the "ENVIRONMENT ==" comparison without stringify-ing #define Linux 1 @@ -164,6 +166,42 @@ bool InternetHostTest::TestGetLocalAddressAsNumber() { return (InternetHost::GetLocalAddressAsNumber() != 0u); } +bool InternetHostTest::TestGetMACAddress() { + InternetHost ih; + StreamString localHostName = "lo"; + const char8 *const interfaceName = "invalidInterfaceName"; + uint8 mac[8]; + uint8 macRef[8]; + MemoryOperationsHelper::Set(macRef, 0, 8); + bool ok = !ih.GetMACAddress(interfaceName, mac); +#if ENVIRONMENT==Linux && ARCHITECTURE==x86_gcc + if (ok) { + struct ifaddrs *addrs, *tmp; + getifaddrs(&addrs); + for (tmp = addrs; (tmp != NULL) && ok; tmp = tmp->ifa_next) { + if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_PACKET) { + MemoryOperationsHelper::Set(mac, 0, 8); + ok = ih.GetMACAddress(tmp->ifa_name, mac); + if(ok){ + if(localHostName != tmp->ifa_name){ + StreamString auxStr = tmp->ifa_name; + auxStr += " = "; + for(uint32 i = 0; i < 6; i++){ + auxStr.Printf("%02x ", mac[i]); + } + REPORT_ERROR_STATIC(ErrorManagement::ParametersError, "%s", auxStr.Buffer()); + ok = (MemoryOperationsHelper::Compare(mac, macRef, 8)!=0); + + } + } + } + } + freeifaddrs(addrs); + } +#endif + return ok; +} + bool InternetHostTest::TestConvertInterfaceNameToInterfaceAddressNumber() { InternetHost ih; bool ok = (ih.ConvertInterfaceNameToInterfaceAddressNumber("invalidInterfaceName") == 0); @@ -291,12 +329,11 @@ bool InternetHostTest::TestSetMulticastInterfaceAddressWithNumber() { bool ok = true; struct ifaddrs *addrs, *tmp; bool found = false; - char8 * addr; + char8 *addr; #if ENVIRONMENT==Linux && ARCHITECTURE==x86_gcc getifaddrs(&addrs); - tmp = addrs; for (tmp = addrs; (tmp != NULL) && !found; tmp = tmp->ifa_next) { //addrs contains several time the same interfaces with different families. Loop until AF_INET is found (ipv4). In case does not exist the test succeeds - if (tmp->ifa_addr->sa_family == AF_INET) { + if (tmp->ifa_addr && tmp->ifa_addr->sa_family == AF_INET) { found = true; in_addr_t aux = ih.ConvertInterfaceNameToInterfaceAddressNumber(tmp->ifa_name); ok = (aux != 0); diff --git a/Test/Core/FileSystem/L1Portability/InternetHostTest.h b/Test/Core/FileSystem/L1Portability/InternetHostTest.h index 177c05060..add769f3f 100644 --- a/Test/Core/FileSystem/L1Portability/InternetHostTest.h +++ b/Test/Core/FileSystem/L1Portability/InternetHostTest.h @@ -103,6 +103,8 @@ class InternetHostTest { */ bool TestGetLocalAddressAsNumber(); + bool TestGetMACAddress(); + /** * @brief Test a valid and invalid interfaceName * @details if no interface is available the test return true diff --git a/Test/GTest/FileSystem/L1Portability/InternetHostGTest.cpp b/Test/GTest/FileSystem/L1Portability/InternetHostGTest.cpp index 8e855310f..9f8bd6644 100644 --- a/Test/GTest/FileSystem/L1Portability/InternetHostGTest.cpp +++ b/Test/GTest/FileSystem/L1Portability/InternetHostGTest.cpp @@ -141,6 +141,11 @@ TEST(FileSystem_L1Portability_InternetHostGTest,TestGetLocalAddressAsNumber) { ASSERT_TRUE(internetHostTest.TestGetLocalAddressAsNumber()); } +TEST(FileSystem_L1Portability_InternetHostGTest,TestGetMACAddress) { + InternetHostTest internetHostTest; + ASSERT_TRUE(internetHostTest.TestGetMACAddress()); +} + TEST(FileSystem_L1Portability_InternetHostGTest,TestConvertInterfaceNameToInterfaceAddressNumber) { InternetHostTest internetHostTest; ASSERT_TRUE(internetHostTest.TestConvertInterfaceNameToInterfaceAddressNumber()); From dda2e0284eb627f72a1868e517089a31a92a02eb Mon Sep 17 00:00:00 2001 From: Llorenc Capella Date: Wed, 10 May 2023 15:03:22 +0200 Subject: [PATCH 2/2] add [] to the delete operator for rtThreadInfo --- Source/Core/Scheduler/L5GAMs/GAMScheduler.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Source/Core/Scheduler/L5GAMs/GAMScheduler.cpp b/Source/Core/Scheduler/L5GAMs/GAMScheduler.cpp index 0e1e738df..da9a4a9df 100644 --- a/Source/Core/Scheduler/L5GAMs/GAMScheduler.cpp +++ b/Source/Core/Scheduler/L5GAMs/GAMScheduler.cpp @@ -76,10 +76,10 @@ GAMScheduler::~GAMScheduler() { delete multiThreadService[1]; } if (rtThreadInfo[0] != NULL) { - delete rtThreadInfo[0]; + delete[] rtThreadInfo[0]; } if (rtThreadInfo[1] != NULL) { - delete rtThreadInfo[1]; + delete[] rtThreadInfo[1]; } }