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
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/scripts/init/src/apply_system_defaults/apply_system_defaults.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/scripts/init/src/apply_system_defaults/apply_system_defaults.c' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/1, 3557 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-TEST-RELEASE-1.tar.gz, file: source/scripts/init/src/apply_system_defaults/apply_system_defaults.c)

Check failure on line 2 in source/scripts/init/src/apply_system_defaults/apply_system_defaults.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/scripts/init/src/apply_system_defaults/apply_system_defaults.c' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/1, 3557 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-RELEASE-TEST-DUNFELL-1.tar.gz, file: source/scripts/init/src/apply_system_defaults/apply_system_defaults.c)

Check failure on line 2 in source/scripts/init/src/apply_system_defaults/apply_system_defaults.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'BSD-Intel' license found in local file 'source/scripts/init/src/apply_system_defaults/apply_system_defaults.c' (Match: rdkb/components/opensource/ccsp/Utopia/rdkb/components/opensource/ccsp/Utopia/2, 3557 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/Utopia/+archive/RDKB-RELEASE-TEST-DUNFELL-2.tar.gz, file: source/scripts/init/src/apply_system_defaults/apply_system_defaults.c)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand Down Expand Up @@ -60,6 +60,7 @@
#include "safec_lib_common.h"

#include <telemetry_busmessage_sender.h>

#define PARTNERS_INFO_FILE "/nvram/partners_defaults.json"
#define PARTNERS_INFO_FILE_ETC "/etc/partners_defaults.json"
#define BOOTSTRAP_INFO_FILE "/opt/secure/bootstrap.json"
Expand Down Expand Up @@ -3317,6 +3318,41 @@
}
#endif

#define DEV_PROP_FILE "/etc/device.properties"
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The macro DEV_PROP_FILE is defined locally within the function scope when it should be defined at file scope with other macros (near lines 64-66). This placement is inconsistent with the established pattern in the codebase where file path macros are defined at the top of the file.

Copilot uses AI. Check for mistakes.
static int addPartnerDefaultsToDevPropFile()
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The function lacks documentation. Add a comment block before the function explaining its purpose, parameters (if any were to be added), return values, and any side effects (modifying /etc/device.properties file). This is especially important since this function modifies a system configuration file.

Copilot uses AI. Check for mistakes.
{
FILE *fp = NULL;
const char *is_bci = "IS_BCI=yes\n";
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we keep this in some kind of array and have a generic runner logic to add the paramaters in array.
This to support , if any additional parameters needed, we can add it in array

//open to check for existence
fp = fopen(DEV_PROP_FILE, "r");
Copy link
Contributor

Choose a reason for hiding this comment

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

can we modify with access call?

if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s does not exist or cannot be accessed",__FUNCTION__,DEV_PROP_FILE);
return 1;
}
fclose(fp); // we don't need it anymore

//open for writing
fp = fopen(DEV_PROP_FILE, "a");
Comment on lines +3327 to +3336
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Opening the file twice (first for read, then for append) creates a race condition window where the file could be deleted, modified, or have its permissions changed between the two operations. Consider combining the operations or using access() to check file existence if the only purpose of the first open is verification.

Copilot uses AI. Check for mistakes.
if (fp == NULL)
{
APPLY_PRINT("[Utopia - %s]File %s couldnot open for writing",__FUNCTION__,DEV_PROP_FILE);
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

Spelling error in error message. "couldnot" should be two separate words: "could not".

Suggested change
APPLY_PRINT("[Utopia - %s]File %s couldnot open for writing",__FUNCTION__,DEV_PROP_FILE);
APPLY_PRINT("[Utopia - %s]File %s could not open for writing",__FUNCTION__,DEV_PROP_FILE);

Copilot uses AI. Check for mistakes.
return 1;
}

if (fputs(is_bci, fp) == EOF)
{
APPLY_PRINT("[Utopia - %s]File %s write failed",__FUNCTION__,DEV_PROP_FILE);
fclose(fp);
return 1;
}

APPLY_PRINT("[Utopia - %s]File %s write successful",__FUNCTION__,DEV_PROP_FILE);

fclose(fp);

return 0;
}
Comment on lines +3322 to +3355
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The function unconditionally appends "IS_BCI=yes" to the file every time it's called, without checking if the entry already exists. This will result in duplicate entries if the program runs multiple times or if the entry is already present. Before appending, check if "IS_BCI" already exists in the file to prevent duplicates.

Copilot uses AI. Check for mistakes.
/*
* main()
*/
Expand Down Expand Up @@ -3531,6 +3567,11 @@

sysevent_close(global_fd, global_id);

Copy link
Contributor

Choose a reason for hiding this comment

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

can you please bring this under ONESTACK_PRODUCT_REQ

if (0 == strcasecmp (PartnerID, "comcast-business"))
{
addPartnerDefaultsToDevPropFile();
Copy link

Copilot AI Jan 20, 2026

Choose a reason for hiding this comment

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

The return value of addPartnerDefaultsToDevPropFile() is not checked. If the function fails to write to the file (returns 1), the error is silently ignored. Consider checking the return value and logging an appropriate error message, similar to how other function calls in this section handle errors (see line 3563-3565).

Copilot uses AI. Check for mistakes.
}

return(0);
}

Loading