Skip to content

lib: replace CURLX_FILE_MODE() with mode_t cast - #23181

Closed
vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:try-mode_t
Closed

vszakats wants to merge 1 commit into
curl:masterfrom
vszakats:try-mode_t

Conversation

@vszakats

@vszakats vszakats commented Sep 30, 2026 •

Copy link
Copy Markdown
Member

mode_t is POSIX.

Note, Windows open() expects int, so only use this in non-Windows
codepaths.

Ref: https://learn.microsoft.com/cpp/c-runtime-library/reference/open-wopen

Suggested-by: Dan Fandrich
Ref: #23158 (comment)
Follow-up to d48f2f4 #23171
Follow-up to be9e603 #23158

@vszakats
vszakats marked this pull request as draft September 30, 2026 08:43
@vszakats

vszakats commented Sep 30, 2026 •

Copy link
Copy Markdown
Member Author

consistent fail in 'CM address-sanitizer H3 c-ares', with libssh:

FAIL 664: 'SFTP correct host key' SFTP, server key check
FAIL 665: 'SCP correct host key' SCP, server key check
FAIL 2007: 'SFTP quote rmdir command with trailing junk' SFTP, --quote

seems unrelated.

It's related to Linuxbrew libssh2 bump from libssh2/1.11.1_5 to libssh2/1.11.1_6, which applied this patch:
https://github.com/libssh2/libssh2/commit/b89858b83d68d7e29e0c5b0bb803f8a68271710c.patch?full_index=1
via:
Homebrew/homebrew-core@ebe712b
Homebrew/homebrew-core#311239
which disabled MD5 by default in libssh2.

@vszakats
vszakats marked this pull request as ready for review September 30, 2026 09:18
@vszakats vszakats changed the title lib: try replacing CURLX_FILE_MODE() with mode_t cast lib: replace CURLX_FILE_MODE() with mode_t cast Sep 30, 2026
@testclutch

This comment was marked as off-topic.

vszakats added a commit that referenced this pull request Sep 30, 2026
Homebrew libssh2 1.11.1_6 revision backported a patch which disabled
legacy algorithms by default, without re-enabling them manually. This
effectively disabled MD5, breaking runtests relying on it. Fix by
disabling these tests when using Homebrew libssh2.

Fixing, in 'CM address-sanitizer H3 c-ares' CI job:
```
FAIL 664: 'SFTP correct host key' SFTP, server key check
FAIL 665: 'SCP correct host key' SCP, server key check
FAIL 2007: 'SFTP quote rmdir command with trailing junk' SFTP, --quote
```
Ref: https://github.com/curl/curl/actions/runs/36691471709/job/109812874116#step:50:4471

Refs:
https://github.com/libssh2/libssh2/commit/b89858b83d68d7e29e0c5b0bb803f8a68271710c.patch
Homebrew/homebrew-core@ebe712b
Homebrew/homebrew-core#311239

Bug: #23181 (comment)

Closes #23182
Note, Windows `open()` expects an `int`, so only use this in non-Windows
codepaths.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟢 Approval recommended

All reviewed changes have been assessed with no unresolved blocking issues.

Review effort: Lite
Findings: None

What changed in this PR

Replaces CURLX_FILE_MODE() with explicit mode_t casts in non-Windows code paths.

Changes:

  • Updates file mode handling for qlog, uploads, temporary files, and fchmod().
  • Removes the obsolete compatibility macro.
  • Preserves Windows-specific handling.
File Description
lib/​vquic/​vquic.c Casts qlog file permissions to mode_t.
lib/​file.c Casts uploaded file permissions to mode_t.
lib/​curlx/​win32-fopen.h Removes the obsolete macro.
lib/​curl_fopen.c Casts file creation and fchmod() modes to mode_t.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@MarcelRaad

Copy link
Copy Markdown
Member

Thanks! If CI likes this, I like it too. Please let me fire up a build on a few more systems, I'll post the results tomorrow morning.

@MarcelRaad MarcelRaad left a comment

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.

Works for all my builds, thanks!

@vszakats vszakats closed this in bc63c15 Oct 1, 2026
@vszakats
vszakats deleted the try-mode_t branch October 1, 2026 07:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Development

Successfully merging this pull request may close these issues.

5 participants