Skip to content
Open
Show file tree
Hide file tree
Changes from 12 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
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
12 changes: 12 additions & 0 deletions 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 @@ -124,6 +134,8 @@ 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);
Expand Down
Loading