You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Describe the problem
The calls to mkstemp() and mkdtemp() from within src/fsutil.cpp do not check the return values. These return values are essential to checks for error conditions. For example, if for some unknown reason mkstemp() fails to create a temporary file, we would not want to continue running as if it was created successfully.
Suggested Fix
Check the return values for errors and if an error occurred, throw std::ios_base::failure exceptions.
I would like to create tests for this. Perhaps we would need to use Google Moc? I would like to learn how that works.
Alternative approaches:
Hopefully the problem would be discovered elsewhere in the code. But would we want to risk it?
The text was updated successfully, but these errors were encountered:
I think we should check the status and throw the exception, but I'm not sure if we should add tests for this since it would require another external dependency (though only for testing).
Agreed. If we used Google Mock for this, then we would probably want to move all of our C++ tests to use Google Test (since they are now part of the same framework).
Also, I looked into Google Mock, and it would not help us with this problem unless we changed how we called the functions to begin with (through an interface class that can be used to override the behavior). I don't want to go through that. Perhaps we could do some link seams (see the third answer at https://stackoverflow.com/questions/2924440/advice-on-mocking-system-calls#2924607).
Bug Report
Describe the problem
The calls to
mkstemp()
andmkdtemp()
from withinsrc/fsutil.cpp
do not check the return values. These return values are essential to checks for error conditions. For example, if for some unknown reasonmkstemp()
fails to create a temporary file, we would not want to continue running as if it was created successfully.Suggested Fix
Check the return values for errors and if an error occurred, throw
std::ios_base::failure
exceptions.I would like to create tests for this. Perhaps we would need to use Google Moc? I would like to learn how that works.
Alternative approaches:
Hopefully the problem would be discovered elsewhere in the code. But would we want to risk it?
The text was updated successfully, but these errors were encountered: