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

Fix safe_strcpy calls #626

Merged
merged 2 commits into from
Oct 25, 2024
Merged

Fix safe_strcpy calls #626

merged 2 commits into from
Oct 25, 2024

Conversation

arnopo
Copy link
Collaborator

@arnopo arnopo commented Oct 21, 2024

Fix issue #625 reported by @jonny-svaerd-arm

Fix safe_strcpy() argument that provides the size of the source string. Indeed, if the source string is of type char*, it is not valid to use sizeof to determine its length. Use strnlen to get the size of the string while ensuring that we have a maximum size.

On the contrary, it is preferable to use sizeof on ept->name, that is an array of char

@arnopo arnopo added this to the Release V2024.10 milestone Oct 22, 2024
Fix the size of the source string passed in argument of safe_strcpy().
In rpmsg_create_ept we can not trust the size of the name
string provided, so we limit the max size to RPMSG_NAME_SIZE.

Update the rpmsg_create_ept documentation to clarify the limit

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
Fix the size of the source string passed in argument of safe_strcpy().
In rpmsg_register_endpoint we can not trust the size of the name
string provided, so we limit the max size to RPROC_MAX_NAME_LEN.

Signed-off-by: Arnaud Pouliquen <arnaud.pouliquen@foss.st.com>
@arnopo
Copy link
Collaborator Author

arnopo commented Oct 23, 2024

The strnlen function is not supported by all compilers. I have replaced, for instance, strnlen(name, RPROC_MAX_NAME_LEN)) by RPROC_MAX_NAME_LEN and added the (already existing) limitation in the API documentation.

@arnopo arnopo requested a review from tnmysh October 23, 2024 08:16
Copy link
Contributor

@edmooring edmooring left a comment

Choose a reason for hiding this comment

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

Looks good to go.

@arnopo arnopo merged commit 71887e7 into OpenAMP:main Oct 25, 2024
5 checks passed
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.

remoteproc/rpmsg: Wrong argument to safe_strcpy()
3 participants