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
9 changes: 7 additions & 2 deletions source/util_api/ansc/AnscPlatform/user_time.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/util_api/ansc/AnscPlatform/user_time.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'IETF' license found in local file 'source/util_api/ansc/AnscPlatform/user_time.c' (Match: rdkb/components/opensource/ccsp/CcspCommonLibrary/rdkb/components/opensource/ccsp/CcspCommonLibrary/1, 392 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspCommonLibrary/+archive/RDKB-TEST-RELEASE-1.tar.gz, file: source/util_api/ansc/AnscPlatform/user_time.c)

Check failure on line 2 in source/util_api/ansc/AnscPlatform/user_time.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'IETF' license found in local file 'source/util_api/ansc/AnscPlatform/user_time.c' (Match: rdkb/components/opensource/ccsp/CcspCommonLibrary/rdkb/components/opensource/ccsp/CcspCommonLibrary/2101, 392 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspCommonLibrary/+archive/rdk-dev-2101.tar.gz, file: source/util_api/ansc/AnscPlatform/user_time.c)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand Down Expand Up @@ -71,6 +71,11 @@
04/03/02 adapted to linux user by Ying Lou

**********************************************************************/
#define _TIME_BITS 64
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include "time.h"

#include "user_base.h"
#include "user_time.h"
#include "safec_lib_common.h"
Expand Down Expand Up @@ -388,9 +393,9 @@
unsigned long
UserGetUtcSeconds( void )
{
time_t timeNow;
int64_t timeNow;

UserGetNtpTime(&timeNow);
UserGetNtpTime((time_t*)&timeNow);

return timeNow;
Comment on lines +396 to 400
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

Casting a pointer to int64_t to time_t* is unsafe. With _TIME_BITS 64 enabled, time_t should already be 64-bit, so a local time_t variable should be used instead. This avoids potential aliasing issues and undefined behavior. Consider: time_t timeNow; UserGetNtpTime(&timeNow); return (unsigned long)timeNow; or change the return type to match the actual data type.

Copilot uses AI. Check for mistakes.
Copy link

Copilot AI Oct 29, 2025

Choose a reason for hiding this comment

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

The function UserGetUtcSeconds returns unsigned long but timeNow is int64_t. On 32-bit systems, this will truncate the 64-bit value to 32 bits, defeating the purpose of using 64-bit time types. The function signature should be updated to return uint64_t or time_t to properly handle 64-bit timestamps.

Copilot uses AI. Check for mistakes.
}
Expand Down
15 changes: 9 additions & 6 deletions source/util_api/ansc/AnscPlatform/user_time_priv.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/util_api/ansc/AnscPlatform/user_time_priv.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'IETF' license found in local file 'source/util_api/ansc/AnscPlatform/user_time_priv.c' (Match: rdkb/components/opensource/ccsp/CcspCommonLibrary/rdkb/components/opensource/ccsp/CcspCommonLibrary/2101, 424 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspCommonLibrary/+archive/rdk-dev-2101.tar.gz, file: source/util_api/ansc/AnscPlatform/user_time_priv.c)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand Down Expand Up @@ -67,6 +67,11 @@
05/01/14 initial revision.

**********************************************************************/
#define _TIME_BITS 64
#define _FILE_OFFSET_BITS 64
#include <sys/types.h>
#include "time.h"

#include "user_base.h"
#include "user_time.h"

Expand Down Expand Up @@ -297,7 +302,6 @@
void
UserSetSystemTime(USER_SYSTEM_TIME* pSystemTime)
{
time_t newTime;
struct tm newtm;
struct timeval newtv;
union semun semopts;
Expand All @@ -317,7 +321,7 @@
newtm.tm_isdst = 1;

#if !defined(_ANSC_LINUX_NO_TM_GMT)
newTime = timegm(&newtm);
int64_t newTime = (int64_t)timegm(&newtm);
/*CID: 62026 Argument cannot be negative*/
if (newTime < 0) {
printf("newTime cant be negative\n");
Expand All @@ -330,7 +334,7 @@
newtm.tm_min, newtm.tm_sec, newtm.tm_isdst);
*/

newtv.tv_sec = (long)newTime;
newtv.tv_sec = newTime;
newtv.tv_usec = 0;

if ( sid == -1 )
Expand Down Expand Up @@ -367,7 +371,6 @@
void
UserSetLocalTime(USER_SYSTEM_TIME* pSystemTime)
{
time_t newTime;
struct tm newtm;
struct timeval newtv;
union semun semopts;
Expand All @@ -390,14 +393,14 @@
newtm.tm_min, newtm.tm_sec, newtm.tm_isdst);


newTime = mktime(&newtm);
int64_t newTime = (int64_t)mktime(&newtm);
/*CID:55942 Argument cannot be negative*/
if (newTime < 0) {
printf("newTime cant be negative\n");
return;
}

newtv.tv_sec = (long)newTime;
newtv.tv_sec = newTime;
newtv.tv_usec = 0;
if ( sid == -1 )
{
Expand Down
7 changes: 4 additions & 3 deletions source/util_api/ccsp_msg_bus/ccsp_base_api_srv.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/util_api/ccsp_msg_bus/ccsp_base_api_srv.c

View workflow job for this annotation

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

FossID License Issue Detected

Source code with 'IETF' license found in local file 'source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c' (Match: rdkb/components/opensource/ccsp/CcspCommonLibrary/rdkb/components/opensource/ccsp/CcspCommonLibrary/2101, 810 lines, url: https://code.rdkcentral.com/r/plugins/gitiles/rdkb/components/opensource/ccsp/CcspCommonLibrary/+archive/rdk-dev-2101.tar.gz, file: source/util_api/ccsp_msg_bus/ccsp_base_api_srv.c)
* following copyright and licenses apply:
*
* Copyright 2015 RDK Management
Expand Down Expand Up @@ -32,7 +32,8 @@
See the License for the specific language governing permissions and
limitations under the License.
**********************************************************************/

#define _TIME_BITS 64
#define _FILE_OFFSET_BITS 64
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -725,7 +726,7 @@
FILE * fd = NULL;

struct timespec time1 = {0};
unsigned long currentTime = 0;
time_t currentTime = 0;
unsigned long deadLockHappen = 0;

time1.tv_sec = 3;
Expand All @@ -747,7 +748,7 @@
info->enterTime = currentTime - info->timepassed ;
CcspTraceWarning((" **** info->timepassed %lu ******\n",info->timepassed));
CcspTraceWarning((" **** info->enterTime %lu ******\n",info->enterTime));
CcspTraceWarning((" **** currentTime %lu ******\n",currentTime));
CcspTraceWarning((" **** currentTime %llu ******\n",currentTime));
}
else
{
Expand Down
Loading