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

Check use of unsafe stdio functions (sprintf(..), vsprintf(..), etc) #80

Open
gavanderhoorn opened this issue Jun 30, 2023 · 4 comments
Labels
good first issue Good for newcomers todo Not an issue, just a TODO
Milestone

Comments

@gavanderhoorn
Copy link
Collaborator

MotoROS2 uses quite a few of the functions in stdio.h which are involved in manipulating in-memory buffers, and potentially unsafe IO operations.

Examples are: printf(..), sprintf(..), snprintf(..), strcpy(..), strncpy(..), etc.

The use of these functions should be audited and checked for any unsafe patterns that may have unintentionally ended up in MotoROS2. If needed, safer versions of these functions should be used.

A complicating factor might be that M+ does not always support the safer variants of these functions.

@gavanderhoorn gavanderhoorn added good first issue Good for newcomers todo Not an issue, just a TODO labels Jun 30, 2023
@gavanderhoorn gavanderhoorn added this to the untargeted milestone Jun 30, 2023
@gavanderhoorn
Copy link
Collaborator Author

Tools like cppcheck and other static analysis tools could potentially assist with this.

@SejalBehere
Copy link
Contributor

I tried using cppcheck and Visual Lint for the analysis of all the files but am not getting any kind of error/warning messages even after the analysisis complete. Cppcheck didn't display any errors/warnings. Then I used cppcheck in Visual Lint and though it did analyze all the files and showed that issues had been found, it still did not display any error/warning messages and instead said "A message database is not currently available for Cppcheck."

I have posted a discussion thread to the cppcheck discussion board. Here is the link to the thread:

https://sourceforge.net/p/cppcheck/discussion/general/thread/7098576e8c/

@gavanderhoorn
Copy link
Collaborator Author

Could you show the command you used to run cppcheck? I've ran it in the past and it required quite a few flags.

@SejalBehere
Copy link
Contributor

I imported the VS project to cppcheck and then ran analysis on the imported files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers todo Not an issue, just a TODO
Projects
None yet
Development

No branches or pull requests

2 participants