Skip to content

vfs/sftpfs: Always zero-initialize struct stat and set st_blksize - #5169

Open
tuffnatty wants to merge 1 commit into
MidnightCommander:masterfrom
tuffnatty:sftpfs-uninitialized-stat
Open

tuffnatty wants to merge 1 commit into
MidnightCommander:masterfrom
tuffnatty:sftpfs-uninitialized-stat

Conversation

@tuffnatty

Copy link
Copy Markdown
Contributor

copy_file_file() uses the st_blksize member of struct stat for buffer size calculation. Uninitialized value results in a memory allocation error.

Proposed changes

Always zero-initialize sftpfs-generated struct stat. Always fill st_blksize in.

Checklist

  • I have referenced the issue(s) resolved by this PR (if any)
  • I have signed-off my contribution with git commit --amend -s
  • Lint and unit tests pass locally with my changes (make indent && make check)
  • I have added tests that prove my fix is effective or that my feature works
  • I have added the necessary documentation (if appropriate)

@github-actions github-actions Bot added needs triage Needs triage by maintainers prio: medium Has the potential to affect progress labels Sep 28, 2026
@github-actions github-actions Bot added this to the Future Releases milestone Sep 28, 2026
@zyv zyv added area: core Issues not related to a specific subsystem area: vfs Virtual File System support and removed needs triage Needs triage by maintainers area: core Issues not related to a specific subsystem labels Sep 29, 2026
Comment thread src/vfs/sftpfs/internal.c
@tuffnatty
tuffnatty force-pushed the sftpfs-uninitialized-stat branch from b13bb10 to 674de79 Compare October 3, 2026 15:20
copy_file_file() uses the st_blksize member of struct stat for buffer
size calculation. Uninitialized value results in a memory allocation
error. This change always zero-initializes the struct, so one non-zero
initialization of st_nlink needs to be moved after a call that now
clears the struct.

Signed-off-by: Phil Krylov <phil@krylov.eu>
@tuffnatty
tuffnatty force-pushed the sftpfs-uninitialized-stat branch from 674de79 to fb1b0b9 Compare October 4, 2026 11:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: vfs Virtual File System support prio: medium Has the potential to affect progress

Development

Successfully merging this pull request may close these issues.

3 participants