Skip to content
Open
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion build_inside_container.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ autoreconf --install
# FLags to print compiler warnings
DEBUG_CFLAGS="-Wall -Werror -Wextra"

export CFLAGS=" ${DEBUG_CFLAGS} -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"
export CFLAGS=" ${DEBUG_CFLAGS} -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/dbus-1.0 -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Hardcoded D-Bus include paths are not portable across different Linux distributions and architectures. The path /usr/lib/x86_64-linux-gnu/dbus-1.0/include is specific to x86_64 Debian/Ubuntu systems. Use pkg-config to detect D-Bus include paths: pkg-config --cflags dbus-1.

Suggested change
export CFLAGS=" ${DEBUG_CFLAGS} -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/dbus-1.0 -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"
DBUS_CFLAGS=$(pkg-config --cflags dbus-1)
export CFLAGS=" ${DEBUG_CFLAGS} ${DBUS_CFLAGS} -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"

Copilot uses AI. Check for mistakes.

export LDFLAGS="-L/usr/lib/x86_64-linux-gnu -lglib-2.0"

Comment on lines +30 to 33
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Hardcoded D-Bus include paths added to CFLAGS. Similar to the Makefile.am issues, these should use pkg-config for portability across different systems and architectures.

Suggested change
export CFLAGS=" ${DEBUG_CFLAGS} -I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/dbus-1.0 -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"
export LDFLAGS="-L/usr/lib/x86_64-linux-gnu -lglib-2.0"
DBUS_CFLAGS="$(pkg-config --cflags dbus-1 2>/dev/null || echo '-I/usr/lib/x86_64-linux-gnu/dbus-1.0/include -I/usr/include/dbus-1.0')"
GLIB_CFLAGS="$(pkg-config --cflags glib-2.0 2>/dev/null || echo '-I/usr/include/glib-2.0 -I/usr/lib/x86_64-linux-gnu/glib-2.0/include')"
export CFLAGS=" ${DEBUG_CFLAGS} ${DBUS_CFLAGS} ${GLIB_CFLAGS} -I${INSTALL_DIR}/include/rtmessage -I${INSTALL_DIR}/include/msgpack -I${INSTALL_DIR}/include/rbus -I${INSTALL_DIR}/include -I/usr/local/include -DFEATURE_SUPPORT_WEBCONFIG -DRDK_LOGGER -DPERSIST_LOG_MON_REF -DDCMAGENT"
GLIB_LDFLAGS="$(pkg-config --libs glib-2.0 2>/dev/null || echo '-L/usr/lib/x86_64-linux-gnu -lglib-2.0')"
export LDFLAGS="${GLIB_LDFLAGS}"

Copilot uses AI. Check for mistakes.
Expand Down
10 changes: 7 additions & 3 deletions source/bulkdata/reportprofiles.c
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@ T2ERROR ReportProfiles_setProfileXConf(ProfileXConf *profile)
{
unregisterDEforCompEventList();
createComponentDataElements();
publishEventsProfileUpdates();
//publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
Comment on lines +318 to +319
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The original publishEventsProfileUpdates() call has been replaced with publishDBUSEventsProfileUpdates(). However, publishDBUSEventsProfileUpdates() currently always returns T2ERROR_FAILURE because its implementation is incomplete (see busInterface.c line 130). This means profile update notifications are not being sent, which could break functionality that depends on these notifications.

Suggested change
//publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
publishEventsProfileUpdates();

Copilot uses AI. Check for mistakes.

Comment on lines +318 to +320
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Same issue: publishEventsProfileUpdates() is commented out. Should be conditional.

Suggested change
//publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
}
else
{
publishDBUSEventsProfileUpdates();

Copilot uses AI. Check for mistakes.
Comment on lines +318 to +320
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The original publishEventsProfileUpdates() calls are commented out in favor of publishDBUSEventsProfileUpdates(). This breaks RBUS mode functionality. For production, either implement proper mode selection or document why RBUS support is being removed.

Suggested change
//publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
publishEventsProfileUpdates();
}
else
{
publishDBUSEventsProfileUpdates();

Copilot uses AI. Check for mistakes.
}
T2ER_StartDispatchThread();

Expand Down Expand Up @@ -1082,7 +1084,8 @@ void ReportProfiles_ProcessReportProfilesBlob(cJSON *profiles_root, bool rprofil
{
createComponentDataElements();
// Notify registered components that profile has received an update
publishEventsProfileUpdates();
//publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
Comment on lines +1087 to +1088
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The publishEventsProfileUpdates() calls are commented out and replaced with publishDBUSEventsProfileUpdates(). This breaks RBUS functionality. The code should conditionally call the appropriate function based on which bus is enabled, rather than completely disabling RBUS support.

Copilot uses AI. Check for mistakes.
getMarkerCompRbusSub(true);
}
hash_map_destroy(receivedProfileHashMap, freeReportProfileHashMap);
Expand Down Expand Up @@ -1451,7 +1454,8 @@ int __ReportProfiles_ProcessReportProfilesMsgPackBlob(void *msgpack, bool checkP
{
createComponentDataElements();
// Notify registered components that profile has received an update
publishEventsProfileUpdates();
// publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
getMarkerCompRbusSub(true);
}
Comment on lines +1457 to 1460
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Same issue: publishEventsProfileUpdates() is commented out and replaced with D-Bus version. This should be conditional based on the enabled bus type.

Suggested change
// publishEventsProfileUpdates();
publishDBUSEventsProfileUpdates();
getMarkerCompRbusSub(true);
}
publishEventsProfileUpdates();
getMarkerCompRbusSub(true);
}
else
{
// Notify registered components via D-Bus when RBUS is not enabled
publishDBUSEventsProfileUpdates();
}

Copilot uses AI. Check for mistakes.
msgpack_unpacked_destroy(&result);
Expand Down
4 changes: 2 additions & 2 deletions source/bulkdata/t2eventreceiver.c
Original file line number Diff line number Diff line change
Expand Up @@ -196,13 +196,13 @@ void T2ER_Push(char* eventName, char* eventValue)
}
else
{
T2Debug("Received eventInfo : %s value : %s\n", eventName, (char* ) eventValue);
T2Info("Received eventInfo : %s value : %s\n", eventName, (char* ) eventValue);
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Typo in log message: "Recieve" should be "Receive".

Copilot uses AI. Check for mistakes.
T2Event *event = (T2Event *) malloc(sizeof(T2Event));
if(event != NULL)
{
event->name = strdup(eventName);
event->value = strdup(eventValue);
T2Debug("Adding eventName : %s eventValue : %s to t2event queue\n", event->name, event->value);
T2Info("Adding eventName : %s eventValue : %s to t2event queue\n", event->name, event->value);
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Debug log level changed to Info level. While this may be useful for debugging the D-Bus implementation, it could generate excessive logs in production. Ensure this change is intentional and consider reverting to T2Debug after the POC phase.

Suggested change
T2Info("Adding eventName : %s eventValue : %s to t2event queue\n", event->name, event->value);
T2Debug("Adding eventName : %s eventValue : %s to t2event queue\n", event->name, event->value);

Copilot uses AI. Check for mistakes.
t2_queue_push(eQueue, (void *) event);
if(!stopDispatchThread)
{
Expand Down
13 changes: 12 additions & 1 deletion source/bulkdata/t2markers.c
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,18 @@ void createComponentDataElements()
char *compName = (char*) Vector_At(componentList, i);
if(compName)
{
regDEforCompEventList(compName, getComponentMarkerList);
T2Info("Register data element for component %s \n", compName);
//TODO componet specific dbus inteface registration like rbus data element registration
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Typo in comment: 'componet' should be 'component'.

Suggested change
//TODO componet specific dbus inteface registration like rbus data element registration
//TODO component specific dbus inteface registration like rbus data element registration

Copilot uses AI. Check for mistakes.
if(T2ERROR_SUCCESS == registerGetMarkerListCallback(getComponentMarkerList))
{
T2Info("Registered get marker list callback for component %s \n", compName);
i = length; // exit for loop because dbus uses common callback for all components
}
Comment on lines +335 to +339
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The loop terminates early when D-Bus callback registration succeeds (i = length at line 338). This means only the first component gets its marker list callback registered for D-Bus. If this is intentional because D-Bus uses a common callback for all components, it should be documented more clearly. Also verify that all components can properly retrieve their marker lists through this single callback.

Copilot uses AI. Check for mistakes.
else
{
T2Error("Failed to register get marker list callback for component %s \n", compName);
}
//regDEforCompEventList(compName, getComponentMarkerList);
Copy link

Copilot AI Feb 3, 2026

Choose a reason for hiding this comment

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

The original RBUS registration call is commented out. For production code, this commented-out code should be removed, or the logic should be restructured to properly support both RBUS and D-Bus modes.

Suggested change
//regDEforCompEventList(compName, getComponentMarkerList);

Copilot uses AI. Check for mistakes.
}
}
pthread_mutex_unlock(&t2CompListMutex);
Expand Down
4 changes: 2 additions & 2 deletions source/ccspinterface/Makefile.am
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ AM_CFLAGS =

lib_LTLIBRARIES = libccspinterface.la

libccspinterface_la_SOURCES = busInterface.c rbusInterface.c
libccspinterface_la_SOURCES = busInterface.c rbusInterface.c dbusInterface.c
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

By adding dbusInterface.c to libccspinterface_la_SOURCES, this PR enables the D-Bus server implementation, which currently contains a stack-based buffer overflow in handle_get_marker_list where a fixed-size char markerListStr[4096] is built via repeated strcat without bounds checks. A component with many or long event markers (loaded from telemetry configuration) can cause this buffer to overflow when GetMarkerList is invoked over D-Bus, leading to memory corruption and potential remote code execution in the telemetry daemon. Before shipping this linkage, harden dbusInterface.c so that construction of the marker list string is strictly length-bounded (e.g., by tracking remaining capacity or using a safe, bounded string-building API) to prevent any writes past the end of the stack buffer.

Suggested change
libccspinterface_la_SOURCES = busInterface.c rbusInterface.c dbusInterface.c
libccspinterface_la_SOURCES = busInterface.c rbusInterface.c

Copilot uses AI. Check for mistakes.
libccspinterface_la_CFLAGS = $(GLIB_CFLAGS)
libccspinterface_la_LDFLAGS = -shared -fPIC -lrbus $(GLIB_LIBS)
libccspinterface_la_LDFLAGS = -shared -fPIC -lrbus -ldbus-1 $(GLIB_LIBS)
if ENABLE_CCSP_SUPPORT
libccspinterface_la_LDFLAGS += -lccsp_common
libccspinterface_la_SOURCES += ccspinterface.c
Expand Down
37 changes: 36 additions & 1 deletion source/ccspinterface/busInterface.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@
#endif

#include "rbusInterface.h"
#include "dbusInterface.h"

static bool isRbus = false ;
static bool isBusInit = false ;
Expand Down Expand Up @@ -59,6 +60,15 @@ static bool busInit( )
T2Debug("%s --RBUS mode is active \n", __FUNCTION__); //CID 158206:Unchecked return value
}
isBusInit = true;

if (dBusInterface_Init() == T2ERROR_SUCCESS)
{
T2Debug("%s --DBUS mode is active \n", __FUNCTION__); //CID 158206:Unchecked return value
}
else
{
T2Error("%s --DBUS init failed \n", __FUNCTION__);
}
Comment on lines 61 to +71
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Initialization logic error: D-Bus interface is always initialized regardless of whether RBUS is enabled or not. Line 64 calls dBusInterface_Init unconditionally after checking isRbusEnabled(). This means both RBUS and D-Bus will be initialized simultaneously, which may not be the intended behavior and could waste resources. The D-Bus initialization should be conditional based on whether RBUS is available.

Suggested change
isBusInit = true;
if (dBusInterface_Init() == T2ERROR_SUCCESS)
{
T2Debug("%s --DBUS mode is active \n", __FUNCTION__); //CID 158206:Unchecked return value
}
else
{
T2Error("%s --DBUS init failed \n", __FUNCTION__);
}
else
{
if (dBusInterface_Init() == T2ERROR_SUCCESS)
{
T2Debug("%s --DBUS mode is active \n", __FUNCTION__); //CID 158206:Unchecked return value
}
else
{
T2Error("%s --DBUS init failed \n", __FUNCTION__);
}
}
isBusInit = true;

Copilot uses AI. Check for mistakes.
Comment on lines +64 to +71
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Design issue: D-Bus interface is always initialized regardless of whether RBUS is available or enabled. This means both bus systems are running simultaneously, which wastes resources and can cause conflicts. The D-Bus initialization should only occur when RBUS is not available, implementing a proper fallback mechanism.

Copilot uses AI. Check for mistakes.
}
T2Debug("%s --out \n", __FUNCTION__);
return isBusInit;
Expand Down Expand Up @@ -112,6 +122,28 @@ Vector* getProfileParameterValues(Vector *paramList, int count)
return profileValueList;
}

T2ERROR publishDBUSEventsProfileUpdates()
{
T2Debug("%s ++in\n", __FUNCTION__);
T2ERROR ret = T2ERROR_FAILURE ;
T2Info("Publishing dbus event for t2profile update notification to components \n");
ret = publishdbusEventsProfileUpdates();

T2Debug("%s --out\n", __FUNCTION__);
return ret;
}

T2ERROR registerGetMarkerListCallback(T2EventMarkerListCallback callback)
{
T2Debug("%s ++in\n", __FUNCTION__);
T2ERROR ret = T2ERROR_FAILURE ;

ret = registerDbusHandlerGetMarkerListCallback(callback);

T2Debug("%s --out\n", __FUNCTION__);
return ret;
}

/**
* Register with right bus call back dpending on dbus/rbus mode
*/
Expand All @@ -124,9 +156,12 @@ T2ERROR registerForTelemetryEvents(TelemetryEventCallback eventCB)
busInit();
}

ret = registerDbusT2EventListener(eventCB);
Copy link

Copilot AI Jan 27, 2026

Choose a reason for hiding this comment

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

Unconditional D-Bus event listener registration: The D-Bus event listener is always registered (line 137) regardless of which bus mode is active. This is called before checking isRbus, meaning D-Bus listener will be registered even in RBUS mode. If this is intentional for dual-bus support, it should be documented. Otherwise, it should be conditional.

Copilot uses AI. Check for mistakes.

if (isRbus)
{
ret = registerRbusT2EventListener(eventCB);
// ret = registerRbusT2EventListener(eventCB);
T2Info("RBUS repeaceled with dbus\n");
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Typo in the info message: "repeaceled" should be "replaced".

Suggested change
T2Info("RBUS repeaceled with dbus\n");
T2Info("RBUS replaced with dbus\n");

Copilot uses AI. Check for mistakes.
Comment on lines +159 to +164
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The RBUS event listener registration is commented out and replaced with D-Bus registration. However, the code still checks if (isRbus) before this block, which means when RBUS is active, it won't register anything. The logic should be updated to handle both RBUS and D-Bus modes properly, or the conditional should be removed if RBUS is being completely replaced.

Copilot uses AI. Check for mistakes.
Comment on lines 127 to +164
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The RBUS event listener registration is commented out and replaced with D-Bus registration. This breaks RBUS functionality when RBUS_SUPPORT_ENABLED is defined. The code should conditionally register with RBUS or D-Bus based on which bus is enabled, not completely disable RBUS registration.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

Typo in log message: 'repeaceled' should be 'replaced'.

Suggested change
T2Info("RBUS repeaceled with dbus\n");
T2Info("RBUS replaced with dbus\n");

Copilot uses AI. Check for mistakes.

Comment on lines +159 to 165
Copy link

Copilot AI Jan 29, 2026

Choose a reason for hiding this comment

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

The RBUS event listener registration is commented out (line 163) and replaced with a D-Bus registration (line 159). However, the condition on line 161 still checks 'if (isRbus)', suggesting RBUS mode is expected. This creates a logic inconsistency where D-Bus is always used regardless of the isRbus flag. Either remove the isRbus check or implement proper mode selection.

Copilot uses AI. Check for mistakes.
#ifdef DCMAGENT
/* Register DCM Events */
Expand Down
4 changes: 3 additions & 1 deletion source/ccspinterface/busInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,14 +93,16 @@ T2ERROR registerForTelemetryEvents(TelemetryEventCallback eventCB);

// Needs to be called only in rBus mode
T2ERROR regDEforCompEventList(const char* componentName, T2EventMarkerListCallback callBackHandler) ;

// Common callback registration for dbus
T2ERROR registerGetMarkerListCallback(T2EventMarkerListCallback callback);
void setT2EventReceiveState(int T2_STATE);

void unregisterDEforCompEventList();

T2ERROR regDEforProfileDataModel(callBackHandlers* cbHandlers);

T2ERROR publishEventsProfileUpdates() ;
T2ERROR publishDBUSEventsProfileUpdates();

#ifdef DCMAGENT
/* DCM RBus event Publish functions */
Expand Down
Loading