Skip to content

curl_fopen optimization#11419

Closed
SaltyMilk wants to merge 3 commits intocurl:masterfrom
SaltyMilk:master
Closed

curl_fopen optimization#11419
SaltyMilk wants to merge 3 commits intocurl:masterfrom
SaltyMilk:master

Conversation

@SaltyMilk
Copy link
Copy Markdown
Contributor

No description provided.

Comment thread lib/fopen.c
*fh = fopen(filename, FOPEN_WRITETEXT);
if(*fh)
return CURLE_OK;
*fh = fopen(filename, FOPEN_WRITETEXT);

Check failure

Code scanning / CodeQL

File created without restricting permissions

A file may be created here with mode 0666, which would make it world-writable.
@gvanem
Copy link
Copy Markdown
Contributor

gvanem commented Jul 10, 2023

No description provided.

WTF? A PR should describe the motivation behind a change. And so what's the optimization here?

Comment thread lib/fopen.c Outdated
if (!*fh)
goto fail;
}
if (fstat(fileno(*fh), &sb) == -1 || !S_ISREG(sb.st_mode))
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make checksrc will tell you that we don't use spaces after if...

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My apologies for the oversight, fixed in next commit.

@SaltyMilk
Copy link
Copy Markdown
Contributor Author

Last commit notes:

  • make checksrc ✅
  • Added 0600 on the fopen to silence code-scanning warning.

@bagder
Copy link
Copy Markdown
Member

bagder commented Jul 11, 2023

Added 0600 on the fopen to silence code-scanning warning.

That's not how fopen() works (it would require the use of open()). The warning is wrong.

@SaltyMilk
Copy link
Copy Markdown
Contributor Author

Sorry about that, another oversight in rush. I believe this should be good to go now.
I'll be more careful for potential future PRs, sorry !

@bagder bagder closed this in 0c66718 Jul 11, 2023
@bagder
Copy link
Copy Markdown
Member

bagder commented Jul 11, 2023

Thanks!

bch pushed a commit to bch/curl that referenced this pull request Jul 19, 2023
@wangdudu321123
Copy link
Copy Markdown

ptitSeb pushed a commit to wasix-org/curl that referenced this pull request Sep 25, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

5 participants