mirror of
https://github.com/RGBCube/serenity
synced 2025-07-25 20:37:35 +00:00
SQLServer: Don't stat()-then-mkdir() when mkdir() alone is enough
Closes a TOCTOU race that SonarCloud complained about. SonarCloud: https://sonarcloud.io/project/issues?id=SerenityOS_serenity&issues=AXuVO_uKk92xXUF3qSVc&open=AXuVO_uKk92xXUF3qSVc
This commit is contained in:
parent
9fd58fd6d8
commit
4c8fe01bff
1 changed files with 3 additions and 10 deletions
|
@ -18,16 +18,9 @@ int main([[maybe_unused]] int argc, [[maybe_unused]] char** argv)
|
|||
return 1;
|
||||
}
|
||||
|
||||
struct stat statbuf;
|
||||
if (stat("/home/anon/sql", &statbuf) != 0) {
|
||||
if (errno != ENOENT) {
|
||||
perror("stat");
|
||||
return 1;
|
||||
}
|
||||
if (mkdir("/home/anon/sql", 0700) != 0) {
|
||||
perror("mkdir");
|
||||
return 1;
|
||||
}
|
||||
if (mkdir("/home/anon/sql", 0700) < 0 && errno != EEXIST) {
|
||||
perror("mkdir");
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (unveil("/home/anon/sql", "rwc") < 0) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue