Skip to content

RDK-60607: Fix for y2k38 issue and integer overflow#442

Merged
karuna2git merged 17 commits intordkcentral:developfrom
dshett549:topic/y2k38_overflow
Feb 22, 2026
Merged

RDK-60607: Fix for y2k38 issue and integer overflow#442
karuna2git merged 17 commits intordkcentral:developfrom
dshett549:topic/y2k38_overflow

Conversation

@dshett549
Copy link
Contributor

Reason For Change: y2k38 issue and integer overflow
Signed-off-by: dshett549 [[DEEPTHICHANDRASHEKAR_SHETTY@comcast.com]

Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
@dshett549 dshett549 requested a review from a team as a code owner February 20, 2026 07:47
Copilot AI review requested due to automatic review settings February 20, 2026 07:47
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates rtmessage/rtrouted message timing and buffer-size handling to address y2k38-related timestamp sizing and integer overflow risks by widening several time/size fields to 64-bit and adding supporting encode/decode and message APIs.

Changes:

  • Switch roundtrip timing fields (T1..T5) in rtMessageHeader from 32-bit/time_t usage to 64-bit encoding/decoding.
  • Add rtMessage_SetUInt64 / rtMessage_GetUInt64 to transport 64-bit values via rtMessage.
  • Widen client read state counters/capacity to 64-bit and add checks to prevent negative/overflowed read sizes and oversize buffer reallocations.

Reviewed changes

Copilot reviewed 10 out of 10 changed files in this pull request and generated 6 comments.

Show a summary per file
File Description
src/rtmessage/rtrouted.c Uses 64-bit T* fields and strengthens read-size handling; updates timeout timing message parsing.
src/rtmessage/rtrouteBase.h Widen rtConnectedClient byte counters/capacity to uint64_t.
src/rtmessage/rtrouteBase.c Mirrors 64-bit read counter/capacity changes and roundtrip timestamp assignments.
src/rtmessage/rtMessageHeader.h Changes T1..T5 types to uint64_t.
src/rtmessage/rtMessageHeader.c Encodes/decodes timestamps as uint64_t and adjusts fixed header size constant.
src/rtmessage/rtMessage.h Adds new UInt64 set/get APIs.
src/rtmessage/rtMessage.c Implements UInt64 set/get via string serialization.
src/rtmessage/rtEncoder.h Declares UInt64 encode/decode helpers.
src/rtmessage/rtEncoder.c Implements UInt64 encode/decode using big-endian conversions.
src/rtmessage/rtConnection.c Updates internal send API to carry 64-bit timing values and emits timing info via new UInt64 message fields.
Comments suppressed due to low confidence (1)

src/rtmessage/rtrouted.c:134

  • rtRouted_TransactionTimingDetails assumes T1..T5 are monotonic seconds since boot and converts them to wall time via boottime, but the timestamps are now uint64_t and at least T1/T4 are populated elsewhere as nanoseconds. This will produce incorrect timestamps and durations (and can overflow when casting to time_t). Update the conversion to match the chosen unit (e.g., split ns into tv_sec/tv_nsec), and make sure all T* fields are generated in that same unit.
  rtTime_Now(&uptime);
  boottime = time(NULL) - uptime.tv_sec; /* To calculate actual boot time of the device
                                            time(NULL) - Time since Epoch time(1st Jan 1970)
                                            uptime.tv_sec - Time since boot of device */
  rtLog_Info("=======================================================================");
  timestamp.tv_sec = (time_t)header_details->T1 + boottime;
  rtTime_ToString(&timestamp, time_buff);
  rtLog_Info("Consumer : %s", header_details->topic);
  rtLog_Info("Provider : %s", header_details->reply_topic);
  rtLog_Info("Time at which consumer sends the request to daemon     : %s", time_buff);
  memset(time_buff, 0, sizeof(time_buff));
  timestamp.tv_sec = (time_t)header_details->T2 + boottime;
  rtTime_ToString(&timestamp, time_buff);
  rtLog_Info("Time at which daemon receives the message from consumer: %s", time_buff);
  memset(time_buff, 0, sizeof(time_buff));
  timestamp.tv_sec = (time_t)header_details->T3 + boottime;
  rtTime_ToString(&timestamp, time_buff);
  rtLog_Info("Time at which daemon writes to provider socket         : %s", time_buff);
  memset(time_buff, 0, sizeof(time_buff));
  timestamp.tv_sec = (time_t)header_details->T4 + boottime;
  rtTime_ToString(&timestamp, time_buff);
  rtLog_Info("Time at which provider sends back the response         : %s", time_buff);
  memset(time_buff, 0, sizeof(time_buff));
  timestamp.tv_sec = (time_t)header_details->T5 + boottime;
  rtTime_ToString(&timestamp, time_buff);
  rtLog_Info("Time at which daemon received the response             : %s", time_buff);
  rtLog_Info("Total duration                                         : %lld seconds", (long long int)(header_details->T5 - header_details->T1));
  rtLog_Info("=======================================================================");

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@rdkcmf-jenkins
Copy link
Contributor

Coverity Issue - Overflowed integer argument

The cast of "msginfo->header.payload_length" to a signed type could result in a negative number.

High Impact, CWE-190
INTEGER_OVERFLOW

Issue location

This issue was discovered outside the diff for this Pull Request. You can find it at:
src/rtmessage/rtConnection.c:1612

Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copilot AI review requested due to automatic review settings February 20, 2026 11:08
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 5 comments.

Comments suppressed due to low confidence (2)

src/rtmessage/rtrouted.c:1570

  • clnt->bytes_read is now uint64_t and is used as an array index in &clnt->read_buffer[clnt->bytes_read]. If bytes_read ever exceeds SIZE_MAX, this index can overflow the pointer arithmetic on 32-bit platforms. Consider validating clnt->bytes_read <= SIZE_MAX (and that it’s <= read_buffer_capacity) before forming the pointer passed to recv().

  bytes_read = recv(clnt->fd, &clnt->read_buffer[clnt->bytes_read], bytes_to_read, MSG_NOSIGNAL);
  if (bytes_read == -1)

src/rtmessage/rtrouteBase.c:367

  • clnt->bytes_read is a uint64_t and is used to index read_buffer in the recv() call. Without ensuring bytes_read <= SIZE_MAX (and within read_buffer_capacity), pointer arithmetic can overflow on 32-bit platforms if the state is corrupted or a malformed header causes extreme sizes.

  bytes_read = recv(clnt->fd, &clnt->read_buffer[clnt->bytes_read], bytes_to_read, MSG_NOSIGNAL);
  if (bytes_read == -1)

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copilot AI review requested due to automatic review settings February 20, 2026 16:54
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 11 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copilot AI review requested due to automatic review settings February 20, 2026 17:26
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 10 out of 10 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copilot AI review requested due to automatic review settings February 21, 2026 06:59
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 21, 2026 07:05
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dshett549 and others added 2 commits February 21, 2026 13:09
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copilot AI review requested due to automatic review settings February 22, 2026 03:58
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 3 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

dshett549 and others added 2 commits February 22, 2026 15:56
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
Copilot AI review requested due to automatic review settings February 22, 2026 18:37
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

karuna2git and others added 2 commits February 22, 2026 15:14
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings February 22, 2026 21:13
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 11 out of 11 changed files in this pull request and generated 5 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@karuna2git karuna2git merged commit d619aa6 into rdkcentral:develop Feb 22, 2026
11 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Feb 22, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants