-
Notifications
You must be signed in to change notification settings - Fork 343
[FileSystem] Add openFileWithDefaultApplication method #5798
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
base: master
Are you sure you want to change the base?
[FileSystem] Add openFileWithDefaultApplication method #5798
Conversation
| success = true; | ||
| #elif defined(__APPLE__) | ||
| const std::string command = "open \"" + filename + "\""; | ||
| if (std::system(command.c_str()) == 0) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
std::system() is not safe ; as a user could call this function with an input crafted to do malicious things...
So the solution would be to sanitize the inputs or the best solution is to use fork() and execvp() (for linux at least.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, sorry I didn't know it was bad practice to use std::system. I'll make the changes for both macOS and linux.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have replaced std::system with posix_spawn for Linux and popen for MacOS.
I haven't tested the MacOS implementation.
Used to open the file where a node or component is implemented or instantiate (see SofaComplianceRobotics/SofaGLFW#92)
By submitting this pull request, I acknowledge that
I have read, understand, and agree SOFA Developer Certificate of Origin (DCO).
Reviewers will merge this pull-request only if