RDK-60607: (cid:559820) Overflowed integer argument rtConnectedClient…#438
RDK-60607: (cid:559820) Overflowed integer argument rtConnectedClient…#438dshett549 wants to merge 4 commits intordkcentral:developfrom
Conversation
…_Read Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
There was a problem hiding this comment.
Pull request overview
This pull request addresses an integer overflow vulnerability (RDK-60607) in the rtConnectedClient_Read function by changing the data types used for tracking buffer sizes from signed 32-bit integers to unsigned 64-bit integers. This prevents overflow issues when handling large message payloads.
Changes:
- Modified struct fields in
rtConnectedClientfrominttouint64_tforbytes_read,bytes_to_read, andread_buffer_capacity - Updated local variable types in
rtConnectedClient_Readfunctions to match the new types (size_tforbytes_to_read,uint64_tforincoming_data_size) - Added
<inttypes.h>include for PRIu64 format specifier - Updated log message format specifiers from
%dto%" PRIu64 "to correctly print uint64_t values
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 8 comments.
| File | Description |
|---|---|
| src/rtmessage/rtrouteBase.h | Changed three struct member types from int to uint64_t (bytes_read, bytes_to_read, read_buffer_capacity) |
| src/rtmessage/rtrouted.c | Updated local variable types, added inttypes.h include, and modified format specifiers in log messages |
| src/rtmessage/rtrouteBase.c | Updated local variable types, added inttypes.h include, and modified format specifiers in log messages |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
There was a problem hiding this comment.
uint64_t bytes_read;
uint64_t bytes_to_read;
uint64_t read_buffer_capacity;
I think it's better to use size_t for these, which result in fewer casts between size_t and uint64_t.
size_t bytes_read;
size_t bytes_to_read;
size_t read_buffer_capacity;
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 4 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@gladish Thats the main reason behind this change. |
2454729 to
02dcfa7
Compare
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| if (incoming_data_size > SIZE_MAX) | ||
| { | ||
| rtLog_Info("Requested read buffer size (%" PRIu64 ") exceeds system maximum. Message will be dropped.", incoming_data_size); | ||
| _rtConnection_ReadAndDropBytes(clnt->fd, clnt->header.payload_length); |
There was a problem hiding this comment.
The function _rtConnection_ReadAndDropBytes expects an 'unsigned int' parameter (as defined in rtConnection.h:270), but clnt->header.payload_length is of type uint32_t. While these types are typically the same size on most platforms, this assumes that unsigned int is at least 32 bits. On platforms where unsigned int is 16 bits, this could cause truncation. Consider either casting with an explicit check, or updating the _rtConnection_ReadAndDropBytes signature to accept uint32_t for better type safety and portability.
| if (incoming_data_size > SIZE_MAX) | ||
| { | ||
| rtLog_Info("Requested read buffer size (%" PRIu64 ") exceeds system maximum. Message will be dropped.", incoming_data_size); | ||
| _rtConnection_ReadAndDropBytes(clnt->fd, clnt->header.payload_length); |
There was a problem hiding this comment.
The function _rtConnection_ReadAndDropBytes expects an 'unsigned int' parameter (as defined in rtConnection.h:270), but clnt->header.payload_length is of type uint32_t. While these types are typically the same size on most platforms, this assumes that unsigned int is at least 32 bits. On platforms where unsigned int is 16 bits, this could cause truncation. Consider either casting with an explicit check, or updating the _rtConnection_ReadAndDropBytes signature to accept uint32_t for better type safety and portability.
Signed-off-by: dshett549 <DEEPTHICHANDRASHEKAR_SHETTY@comcast.com>
ReasonForChange: (cid:559820) Overflowed integer argument rtConnectedClient_Read
Priority: P1
Signed-off-by: dshett549 [DEEPTHICHANDRASHEKAR_SHETTY@comcast.com]