Skip to content
Closed
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
11 changes: 11 additions & 0 deletions source/MoCASsp/ssp_main.c
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* If not stated otherwise in this file or this component's Licenses.txt file the

Check failure on line 2 in source/MoCASsp/ssp_main.c

View workflow job for this annotation

GitHub Actions / call-fossid-workflow / Fossid Annotate PR

FossID License Issue Detected

Source code with 'Apache-2.0' license found in local file 'source/MoCASsp/ssp_main.c' (Match: rdkb/components/opensource/ccsp/CcspMoCA/rdkb/components/opensource/ccsp/CcspMoCA/2102, 408 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspMoCA/+archive/rdk-dev-2102.tar.gz, file: source/MoCASsp/ssp_main.c)
* following copyright and licenses apply:
*
* Copyright 2016 RDK Management
Expand Down Expand Up @@ -133,6 +133,10 @@

funcNames = backtrace_symbols( tracePtrs, count );

/* COVERITY_TEST_HIGH: NULL_RETURNS - Dereferencing funcNames before NULL check */
/* This is an intentional Coverity test issue - backtrace_symbols may return NULL */
printf("First trace: %s\n", funcNames[0]);

if ( funcNames ) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Coverity Issue - Dereference before null check

Null-checking "funcNames" suggests that it may be null, but it has already been dereferenced on all paths leading to the check.

Medium Impact, CWE-476
REVERSE_INULL

// Print the stack trace
Comment on lines +137 to 141
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

funcNames is dereferenced before any NULL check (and before verifying count > 0). If backtrace_symbols() returns NULL or count == 0, funcNames[0] is undefined behavior and can crash during signal handling. Move the print after the if (funcNames) block (and guard on count > 0), or remove this dereference entirely outside of Coverity-only builds.

Suggested change
/* This is an intentional Coverity test issue - backtrace_symbols may return NULL */
printf("First trace: %s\n", funcNames[0]);
if ( funcNames ) {
// Print the stack trace
/* This was previously an intentional Coverity test issue - backtrace_symbols may return NULL */
if ( funcNames ) {
// Print the stack trace
if (count > 0) {
printf("First trace: %s\n", funcNames[0]);
}

Copilot uses AI. Check for mistakes.
for( i = 0; i < count; i++ )
Expand Down Expand Up @@ -242,6 +246,11 @@
errno_t rc = -1;
int ind = -1;

/* COVERITY_TEST_LOW: UNUSED_VALUE - Variable assigned but never used */
/* This is an intentional Coverity test issue - dead store */
int unused_test_var = 42;
unused_test_var = 100;

Comment on lines +249 to +253
Copy link

Copilot AI Feb 27, 2026

Choose a reason for hiding this comment

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

The unused_test_var assignments are dead stores (the variable is never read). This adds noise and may trigger compiler warnings; if this is only for static-analysis validation, consider guarding it behind a dedicated Coverity-test macro or removing it from production code paths.

Suggested change
/* COVERITY_TEST_LOW: UNUSED_VALUE - Variable assigned but never used */
/* This is an intentional Coverity test issue - dead store */
int unused_test_var = 42;
unused_test_var = 100;

Copilot uses AI. Check for mistakes.
extern ANSC_HANDLE bus_handle;
char *subSys = NULL;
DmErr_t err;
Expand Down Expand Up @@ -353,6 +362,8 @@
check_component_crash(MOCA_INIT_FILE_BOOTUP);
//CID 276408 : UNCHECKED RETURN VALUE
int check_var = creat("/tmp/moca_initialized",S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH);
/* COVERITY_TEST_MEDIUM: RESOURCE_LEAK - File descriptor not closed */
/* This is an intentional Coverity test issue - missing close(check_var) */
if ( check_var == -1 ){
fprintf(stderr, "Error in creating /tmp/moca_initialized : %s\n", strerror(errno));
exit(1);
Expand Down
Loading