Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
718c5f9
*fix(ASN1): fix buffer cleanup and length parsing**
workkavint-ship-it May 29, 2026
776379c
fix(DataElementFile): null check MapViewOfFile and fix inverted handl…
workkavint-ship-it May 29, 2026
c7961f0
fix(ResourceMonitor): guard readlink failure and malloc null in Worker
workkavint-ship-it May 29, 2026
6ab3f50
fix(FileSystem): fix unreachable FindClose causing handle leak on Win…
workkavint-ship-it May 29, 2026
f5468de
fix(IPFrame): remove spurious & in DestinationMAC memcpy
workkavint-ship-it May 29, 2026
a15e437
fix(Netlink): move constructor was clearing itself instead of the source
workkavint-ship-it May 29, 2026
964d3c4
fix(RequestResponse): fix State() wrong member and Response() copy-pa…
workkavint-ship-it May 29, 2026
aa3e460
fix(NetworkInfo): null deref in MACAddress and ifaddrs leak on macOS
workkavint-ship-it May 29, 2026
2d43bb8
fix(SerialPort): guard calloc result before pointer arithmetic
workkavint-ship-it May 29, 2026
48bffe9
fix(SystemInfo): initialize m_pageSize on Apple to avoid divide by zero
workkavint-ship-it May 29, 2026
38334d2
fix(WarningReportingControl): IsModuleExcluded compared wrong contain…
workkavint-ship-it May 29, 2026
106ca81
fix(DataElement): fix reversed subtraction in Size() causing underflow
workkavint-ship-it May 29, 2026
3e7bd0b
fix(SocketPort): ensure null termination after strncpy for interface …
workkavint-ship-it May 29, 2026
7398fba
fix(NetworkInfo): restore missing closing brace in LoadAdapterInfo
workkavint-ship-it May 29, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions Source/core/ASN1.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,12 +52,10 @@ namespace Core {
{
if (_buffer != nullptr) {
_buffer[0] = 1;
PUSH_WARNING(DISABLE_WARNING_CONSTANT_LOGICAL_OPERAND)
_buffer[1] = (length & 0xFF);
_buffer[2] = ((length >> 8) && 0xFF);
_buffer[2] = ((length >> 8) & 0xFF);
_buffer[3] = (length & 0xFF);
_buffer[4] = ((length >> 8) && 0xFF);
POP_WARNING()
_buffer[4] = ((length >> 8) & 0xFF);
}
}
Buffer(const Buffer& copy)
Expand Down Expand Up @@ -134,7 +132,7 @@ POP_WARNING()
{
if (_buffer != nullptr) {
if (_buffer[0] == 1) {
delete _buffer;
delete[] _buffer;
} else {
_buffer[0] = _buffer[0] - 1;
}
Expand Down
2 changes: 1 addition & 1 deletion Source/core/DataElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@ POP_WARNING()

inline uint64_t Size() const
{
return (m_Offset - m_Buffer.Size());
return (m_Buffer.Size() - m_Offset);
}

inline void SkipBytes(const unsigned int bytes)
Expand Down
7 changes: 4 additions & 3 deletions Source/core/DataElementFile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,9 @@ namespace Core {

void* newBuffer = (::MapViewOfFile(m_MemoryMappedFile, flags, 0, 0, mapSize));

// Seems like everything succeeded. Lets map it.
UpdateCache(0, static_cast<uint8_t*>(newBuffer), requiredSize, mapSize);
if (newBuffer != nullptr) {
UpdateCache(0, static_cast<uint8_t*>(newBuffer), requiredSize, mapSize);
}
}
}
}
Expand Down Expand Up @@ -166,7 +167,7 @@ namespace Core {
}
}

if (m_MemoryMappedFile == INVALID_HANDLE_VALUE) {
if (m_MemoryMappedFile != INVALID_HANDLE_VALUE) {
DWORD flags = ((m_Flags & File::USER_READ) != 0 ? FILE_MAP_READ : 0) | ((m_Flags & File::USER_WRITE) != 0 ? FILE_MAP_WRITE : 0);

void* newBuffer = ::MapViewOfFileEx(m_MemoryMappedFile, flags, 0, 0, static_cast<SIZE_T>(requestedSize), Buffer());
Expand Down
2 changes: 0 additions & 2 deletions Source/core/FileSystem.h
Original file line number Diff line number Diff line change
Expand Up @@ -753,8 +753,6 @@ POP_WARNING()
}
void Reset()
{
_dirFD = INVALID_HANDLE_VALUE;

if (_dirFD != INVALID_HANDLE_VALUE) {
::FindClose(_dirFD);
_dirFD = INVALID_HANDLE_VALUE;
Expand Down
2 changes: 1 addition & 1 deletion Source/core/IPFrame.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ namespace Core {
return (&(_buffer[0]));
}
void DestinationMAC(const uint8_t MACAddress[]) {
memcpy(&(_buffer[0]), &MACAddress, MACSize);
memcpy(&(_buffer[0]), MACAddress, MACSize);
}
uint8_t* Frame() {
return (SIZE > 0 ? &(_buffer[HeaderSize]) : nullptr);
Expand Down
6 changes: 3 additions & 3 deletions Source/core/Netlink.h
Original file line number Diff line number Diff line change
Expand Up @@ -175,9 +175,9 @@ namespace Core {
, _flags(move._flags)
, _mySequence(move._mySequence)
{
_type = NLMSG_DONE;
_flags = 0;
_mySequence = ~0;
move._type = NLMSG_DONE;
move._flags = 0;
move._mySequence = ~0;
}
virtual ~Netlink() = default;

Expand Down
8 changes: 5 additions & 3 deletions Source/core/NetworkInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ namespace Core {
string result;
PIP_ADAPTER_ADDRESSES info = LoadAdapterInfo(_index);

if (info->PhysicalAddressLength != 0) {
if ((info != nullptr) && (info->PhysicalAddressLength != 0)) {
ConvertMACToString(info->PhysicalAddress, static_cast<uint8_t>(info->PhysicalAddressLength), delimiter, result);
}
return (result);
Expand Down Expand Up @@ -451,7 +451,7 @@ namespace Core {

PIP_ADAPTER_ADDRESSES info = LoadAdapterInfo(_index);

if (info->PhysicalAddressLength != 0) {
if ((info != nullptr) && (info->PhysicalAddressLength != 0)) {
ASSERT(length >= info->PhysicalAddressLength);
::memcpy(buffer, info->PhysicalAddress, info->PhysicalAddressLength);
if (length > info->PhysicalAddressLength) {
Expand Down Expand Up @@ -561,7 +561,7 @@ namespace Core {
Adapters adapters;
if (!getifaddrs(&interfaces)) {

struct ifaddrs* index = interfaces->ifa_next;
struct ifaddrs* index = interfaces;
while (index != nullptr) {

Adapters::iterator adapterIndex = adapters.find(index->ifa_name);
Expand All @@ -583,6 +583,8 @@ namespace Core {
addresses = index->second;
}
}

freeifaddrs(interfaces);
}
return adapters.size();
}
Expand Down
4 changes: 2 additions & 2 deletions Source/core/RequestResponse.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ namespace Platform {
public:
inline RequestResponseState State() const
{
return (m_Responded);
return (m_State);
}

inline REQUEST& Request()
Expand All @@ -91,7 +91,7 @@ namespace Platform {

inline RESPONSE& Response()
{
return (*m_Request);
return (*m_Response);
}

private:
Expand Down
16 changes: 11 additions & 5 deletions Source/core/ResourceMonitor.h
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,12 @@ namespace Core {
char procfn[64];
snprintf(procfn, sizeof(procfn), "/proc/self/fd/%d", info.descriptor);

size_t len = readlink(procfn, info.filename, sizeof(info.filename) - 1);
info.filename[len] = '\0';
ssize_t len = readlink(procfn, info.filename, sizeof(info.filename) - 1);
if (len >= 0) {
info.filename[len] = '\0';
} else {
info.filename[0] = '\0';
}
#endif
#ifdef __WINDOWS__
info.monitor = 0;
Expand Down Expand Up @@ -410,9 +414,11 @@ POP_WARNING()
// Resize the array to fit..
_descriptorArray = static_cast<::pollfd*>(::malloc(sizeof(::pollfd) * _descriptorArrayLength));

_descriptorArray[0].fd = _signalDescriptor;
_descriptorArray[0].events = POLLIN;
_descriptorArray[0].revents = 0;
if (_descriptorArray != nullptr) {
_descriptorArray[0].fd = _signalDescriptor;
_descriptorArray[0].events = POLLIN;
_descriptorArray[0].revents = 0;
}
}

int filledFileDescriptors = 1;
Expand Down
6 changes: 4 additions & 2 deletions Source/core/SerialPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -934,8 +934,10 @@ void SerialPort::Read(const uint16_t readBytes)

uint8_t* allocatedMemory = static_cast<uint8_t*>(::calloc(_sendBufferSize + _receiveBufferSize, 1));

_sendBuffer = allocatedMemory;
_receiveBuffer = &(allocatedMemory[_sendBufferSize]);
if (allocatedMemory != nullptr) {
_sendBuffer = allocatedMemory;
_receiveBuffer = &(allocatedMemory[_sendBufferSize]);
}

}

Expand Down
2 changes: 2 additions & 0 deletions Source/core/SocketPort.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -883,10 +883,12 @@ namespace Thunder {
struct ifreq interface;
#ifdef __APPLE__
strncpy(interface.ifr_name, specificInterface.c_str(), IFNAMSIZ - 1);
interface.ifr_name[IFNAMSIZ - 1] = '\0';
int index = if_nametoindex(interface.ifr_name);
if (::setsockopt(l_Result, IPPROTO_IP, IP_BOUND_IF, (const char*)&index, sizeof(index)) < 0) {
#else
strncpy(interface.ifr_ifrn.ifrn_name, specificInterface.c_str(), IFNAMSIZ - 1);
interface.ifr_ifrn.ifrn_name[IFNAMSIZ - 1] = '\0';

if (::setsockopt(l_Result, SOL_SOCKET, SO_BINDTODEVICE, (const char*)&interface, sizeof(interface)) < 0) {
#endif
Expand Down
2 changes: 1 addition & 1 deletion Source/core/SystemInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ namespace Core {
#ifdef __APPLE__
m_uptime = 0;
m_totalram = 0;
m_pageSize = 0;
m_pageSize = static_cast<uint32_t>(sysconf(_SC_PAGESIZE));
m_freeram = 0;
m_totalswap=0;
m_freeswap=0;
Expand Down
2 changes: 1 addition & 1 deletion Source/core/WarningReportingControl.h
Original file line number Diff line number Diff line change
Expand Up @@ -165,7 +165,7 @@ namespace WarningReporting {
}
bool IsModuleExcluded(const string& module) const
{
return _modules.find(module) != _callsigns.end();
return _modules.find(module) != _modules.end();
}
void InsertCallsign(const string& callsign)
{
Expand Down
Loading