-
Notifications
You must be signed in to change notification settings - Fork 254
lib/commonio.c: Use unpredictable temporary names #1497
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?
Conversation
31a3f54 to
718ccee
Compare
4d9ab38 to
92e2db5
Compare
92e2db5 to
82b351e
Compare
e22b9ab to
da37106
Compare
alejandro-colomar
left a comment
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.
LGTM. Thanks!
Reviewed-by: Alejandro Colomar <[email protected]>
| FILE *bkfp; | ||
| int c; | ||
|
|
||
| stprintf_a(tmpf, "%s.cioXXXXXX", name); |
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 do wish that this and the next stprintf_a also returned an error if
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.
Yeah, we could return -1 if it fails. After all, this function already reports some errors, and this is clearly an error.
It doesn't make sense to keep a file around if it's not even a proper backup. Signed-off-by: Tobias Stoeckmann <[email protected]>
Make sure that an attacker with sufficient privileges cannot simply create a file with expected temporary name to retrieve content of previous and/or future database. Signed-off-by: Tobias Stoeckmann <[email protected]>
Make sure that enough bytes exist for file name of temporary file which is used to construct the next database file. While at it, use a better variable name. Signed-off-by: Tobias Stoeckmann <[email protected]>
da37106 to
d4e220d
Compare
Make sure that an attacker with sufficient privileges cannot simply create a file with expected temporary name to retrieve content of previous and/or future database.
Not as thoroughly tested as usual, but given that #1485 is basically the same and planned to be added to 4.19.1, this should be investigated as well.
In fact, this one is slightly worse because it affects every database write, even the ones with
--prefixwhich could point into directories which are not as protected as/etc.Still no serious security issue in my point of view, but better be safe than sorry and protect against it.