Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RDKCOM-5109 RDKBDEV-2974: fix rtrouted crash is seen with an invalid DML query #226

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

pradeeptakdas
Copy link
Contributor

Reason for change:
When a dmcli query is made with a large number of dots, rtrouted crashes. For example: dmcli eRT getv Device.NAT.X_CISCO_COM_DMZ.InternalIP

The reason is that the tokenizeExpression function splits the datamodel path based on dots and writes into the workTokens array without checking the number of elements being written.
This causes a buffer overflow if the number of dots is more than the size of the workTokens array (32).
[Solution]
Add some checks in tokenizeExpression to avoid overflowing the workTokens and workBuffer arrays. Test Procedure:
Run 'dmcli eRT getv Device.NAT.X_CISCO_COM_DMZ.InternalIP' Verify that rtrouted doesn't crash
Run 'rbuscli get' with a path that's more than 512 characters in length Verify that rtrouted doesn't crash
Test Procedure: Sanity.
Risks: None.

Signed-off-by: Hamza Ben Zekri [email protected]

@CLAassistant
Copy link

CLAassistant commented Oct 22, 2024

CLA assistant check
All committers have signed the CLA.

@pradeeptakdas
Copy link
Contributor Author

Internal ticket for tracking https://ccp.sys.comcast.net/browse/RDKCOM-5109

Reason for change:
When a dmcli query is made with a large number of dots, rtrouted crashes.
For example: dmcli eRT getv Device.NAT.X_CISCO_COM_DMZ.InternalIP

The reason is that the tokenizeExpression function splits the datamodel
path based on dots and writes into the workTokens array without checking
the number of elements being written.
This causes a buffer overflow if the number of dots is more than the size
of the workTokens array (32).
[Solution]
Add some checks in tokenizeExpression to avoid overflowing the workTokens and workBuffer arrays.
Test Procedure:
Run 'dmcli eRT getv Device.NAT.X_CISCO_COM_DMZ.InternalIP'
Verify that rtrouted doesn't crash
Run 'rbuscli get' with a path that's more than 512 characters in length
Verify that rtrouted doesn't crash
Test Procedure: Sanity.
Risks: None.
Signed-off-by: Hamza Ben Zekri <[email protected]>
@pradeeptakdas pradeeptakdas changed the title RDKBDEV-2974: fix rtrouted crash is seen with an invalid DML query RDKCOM-5109 RDKBDEV-2974: fix rtrouted crash is seen with an invalid DML query Nov 14, 2024
@karuna2git
Copy link
Contributor

Hey @pradeeptakdas ,
The change solves the problem of NOT crashing; but tokenizeExpression() must return failure when it finds more than 32 dots in the DML name and it must return failure when the DML name is longer than 512. So that the topic wont be added or accessed.

This is good find and could you please enhance it a bit and share it as appropriate fix?

Thanks,
Karunakaran A

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants