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
1 change: 1 addition & 0 deletions recipes-connectivity/bluez5/bluez5_5.48.bbappend
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ SRC_URI:append = " \
file://bluez-5.48-068-RDKOSS-553-stream-use-after-free.patch \
file://bluez-5.48-069-RDKEMW-11885-UAF-in-messagefilter.patch \
file://bluez-5.48-070-ES1-2351-remove-corrupted-hog.patch \
file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

PR description states "Risks: Low", but this change introduces an intentional NULL dereference and memory leak into BlueZ for all builds (via SRC_URI). Unless this is strictly gated to Coverity-only builds, the operational risk is high (potential crash under OOM). Please update the PR description risk assessment or change the implementation to ensure production builds are unaffected.

Copilot uses AI. Check for mistakes.
"

Comment on lines +63 to 65

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

Adding this patch to SRC_URI makes the intentional crash/leak injection apply to all builds of bluez5_5.48, not just Coverity runs. If the goal is to validate Coverity, please make this patch conditional (e.g., using bb.utils.contains on a dedicated DISTRO_FEATURE like 'coverity', or a recipe override) so production images are unaffected, or keep it out of this layer entirely.

Suggested change
file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch \
"
"
SRC_URI:append = "${@bb.utils.contains('DISTRO_FEATURES', 'coverity', ' file://bluez-5.48-071-RDKOSS-899-bluez-for-coverity-check.patch', '', d)}"

Copilot uses AI. Check for mistakes.
FILESEXTRAPATHS:prepend := "${THISDIR}/${PN}:"
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
diff --git a/gdbus/watch.c b/gdbus/watch.c
index 447e48671..17878cafb 100644
--- a/gdbus/watch.c
+++ b/gdbus/watch.c
@@ -166,6 +166,20 @@ static gboolean add_match(struct filter_data *data,
{
DBusError err;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
+ char *coverity_test_buf;
+
+ /* Intentionally allocate memory and do not free it on all paths
+ * Used to validate Coverity RESOURCE_LEAK detection
+ */
+ coverity_test_buf = g_new0(char, 16);
+
+ /* Intentionally introduce NULL dereference before NULL check
+ * Used to validate Coverity NULL_DEREFERENCE detection
+ */
+ coverity_test_buf[0] = 'C';
+
+ if (coverity_test_buf == NULL)
+ return FALSE;

format_rule(data, rule, sizeof(rule));
dbus_error_init(&err);
@@ -178,6 +192,7 @@ static gboolean add_match(struct filter_data *data,
return FALSE;
}

+ /* coverity_test_buf intentionally not freed */
Comment on lines +5 to +30

Copilot AI Apr 21, 2026

Copy link

Choose a reason for hiding this comment

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

This patch intentionally introduces a NULL dereference (dereferencing coverity_test_buf before checking for NULL) and an unconditional memory leak. Even if meant for Coverity validation, including this in the BlueZ source applied by the recipe can cause real runtime crashes under low-memory conditions and degrades code quality. Please avoid shipping intentional defects: either remove this patch from the normal build, or guard the injected code behind a compile-time flag and only enable/apply it in a dedicated Coverity-only build configuration (e.g., conditional SRC_URI based on a DISTRO_FEATURE/PACKAGECONFIG/override).

Suggested change
@@ -166,6 +166,20 @@ static gboolean add_match(struct filter_data *data,
{
DBusError err;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
+ char *coverity_test_buf;
+
+ /* Intentionally allocate memory and do not free it on all paths
+ * Used to validate Coverity RESOURCE_LEAK detection
+ */
+ coverity_test_buf = g_new0(char, 16);
+
+ /* Intentionally introduce NULL dereference before NULL check
+ * Used to validate Coverity NULL_DEREFERENCE detection
+ */
+ coverity_test_buf[0] = 'C';
+
+ if (coverity_test_buf == NULL)
+ return FALSE;
format_rule(data, rule, sizeof(rule));
dbus_error_init(&err);
@@ -178,6 +192,7 @@ static gboolean add_match(struct filter_data *data,
return FALSE;
}
+ /* coverity_test_buf intentionally not freed */
@@ -166,6 +166,6 @@ static gboolean add_match(struct filter_data *data,
{
DBusError err;
char rule[DBUS_MAXIMUM_MATCH_RULE_LENGTH];
format_rule(data, rule, sizeof(rule));
dbus_error_init(&err);
@@ -178,6 +178,6 @@ static gboolean add_match(struct filter_data *data,
return FALSE;
}

Copilot uses AI. Check for mistakes.
data->handle_func = filter;
data->registered = TRUE;

Loading