Skip to content
Open
Changes from all commits
Commits
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
20 changes: 19 additions & 1 deletion src/DebugConfiguration.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ SOFTWARE.*/
#include "configuration.h"

#include "DebugConfiguration.h"
#include "gps/RTC.h"
#include <time.h>

#ifdef ARCH_PORTDUINO
#include "platform/portduino/PortduinoGlue.h"
Expand Down Expand Up @@ -176,7 +178,23 @@ inline bool Syslog::_sendLog(uint16_t pri, const char *appName, const char *mess

this->_client->print('<');
this->_client->print(pri);
this->_client->print(F(">1 - "));
this->_client->print(F(">1 "));

// Format RFC5424 timestamp if valid time is available.
uint32_t timestamp_sec = getValidTime(RTCQualityDevice, false);
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The RTCQualityDevice enum value should be qualified with the RTCQuality:: namespace. Based on other usages in the codebase (e.g., in RedirectablePrint.cpp, NMEAWPL.cpp), this should be RTCQuality::RTCQualityDevice.

uint32_t timestamp_sec = getValidTime(RTCQuality::RTCQualityDevice, false);
Suggested change
uint32_t timestamp_sec = getValidTime(RTCQualityDevice, false);
uint32_t timestamp_sec = getValidTime(RTCQuality::RTCQualityDevice, false);

Copilot uses AI. Check for mistakes.
if (timestamp_sec != 0) {
time_t timestamp = (time_t)timestamp_sec;
struct tm *time_info = gmtime(&timestamp);
char timestamp_buffer[21];
snprintf(timestamp_buffer, sizeof(timestamp_buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ",
time_info->tm_year + 1900, time_info->tm_mon + 1, time_info->tm_mday,
time_info->tm_hour, time_info->tm_min, time_info->tm_sec);
this->_client->print(timestamp_buffer);
} else {
this->_client->print(SYSLOG_NILVALUE);
Comment on lines +188 to +194
Copy link

Copilot AI Nov 17, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The gmtime() function can return NULL if the time value is invalid. This could lead to a null pointer dereference when accessing time_info->tm_year. Add a null check before using the returned pointer.

struct tm *time_info = gmtime(&timestamp);
if (time_info != NULL) {
    char timestamp_buffer[21];
    snprintf(timestamp_buffer, sizeof(timestamp_buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ",
             time_info->tm_year + 1900, time_info->tm_mon + 1, time_info->tm_mday,
             time_info->tm_hour, time_info->tm_min, time_info->tm_sec);
    this->_client->print(timestamp_buffer);
} else {
    this->_client->print(SYSLOG_NILVALUE);
}
Suggested change
char timestamp_buffer[21];
snprintf(timestamp_buffer, sizeof(timestamp_buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ",
time_info->tm_year + 1900, time_info->tm_mon + 1, time_info->tm_mday,
time_info->tm_hour, time_info->tm_min, time_info->tm_sec);
this->_client->print(timestamp_buffer);
} else {
this->_client->print(SYSLOG_NILVALUE);
if (time_info != NULL) {
char timestamp_buffer[21];
snprintf(timestamp_buffer, sizeof(timestamp_buffer), "%04d-%02d-%02dT%02d:%02d:%02dZ",
time_info->tm_year + 1900, time_info->tm_mon + 1, time_info->tm_mday,
time_info->tm_hour, time_info->tm_min, time_info->tm_sec);
this->_client->print(timestamp_buffer);
} else {
this->_client->print(SYSLOG_NILVALUE);
}

Copilot uses AI. Check for mistakes.
}

this->_client->print(' ');
this->_client->print(this->_deviceHostname);
this->_client->print(' ');
this->_client->print(appName);
Expand Down
Loading