Skip to content

Fix wolfSSH_SFTPNAME_readdir with FATFS - #973

Merged
ejohnstown merged 2 commits into
wolfSSL:masterfrom
HOPPECKE-Systemtechnik:fix-wolfSSH_SFTPNAME_readdir-with-fatfs
May 13, 2026
Merged

Fix wolfSSH_SFTPNAME_readdir with FATFS#973
ejohnstown merged 2 commits into
wolfSSL:masterfrom
HOPPECKE-Systemtechnik:fix-wolfSSH_SFTPNAME_readdir-with-fatfs

Conversation

@J-Goldacker

Copy link
Copy Markdown
Contributor

This PR fixes the following issues for wolfSSH_SFTPNAME_readdir with FATFS:

  • f_readdir returns FR_OK with empty string in fname when there is no directory entry left
  • wolfSSH_SFTPNAME_free would crash because of a double free in case wolfSSH_SFTPNAME_readdir returns an error and frees fName without setting it to NULL

otherwise wolfSSH_SFTPNAME_free would crash afterwards
@wolfSSL-Bot

Copy link
Copy Markdown

Can one of the admins verify this patch?

@dgarske

dgarske commented May 12, 2026

Copy link
Copy Markdown
Member

Hi @J-Goldacker , no contributor agreement on file. Assigning to @ejohnstown to review and make recommendation.

@J-Goldacker

Copy link
Copy Markdown
Contributor Author

Hi @dgarske, thank you for assigning the PR.

Is this the correct way the give bugfixes we found back to you? (We have licensed your software for Hoppecke Systemtechnik GmbH.)

@ejohnstown One thing, I wanted to mention:
The double free problem for fname can occur on other places too. We only fixed what we needed to. Another approach would be to not free fname on error and rely on the fact, that wolfSSH_SFTPNAME_free is called after an error is returned. (But we chose the safer approach.)

@ejohnstown

ejohnstown commented May 13, 2026

Copy link
Copy Markdown
Contributor

Is this the correct way the give bugfixes we found back to you?

This is fine. In this case, since there were 14 other locations to change, telling us about the bug and then letting us fix it would be better, but that is mostly because of it only being one PR instead of two. Macht nichts. : ]

Thank you for the fix and the bug report.

@ejohnstown
ejohnstown merged commit 0838634 into wolfSSL:master May 13, 2026
137 of 139 checks passed
@J-Goldacker
J-Goldacker deleted the fix-wolfSSH_SFTPNAME_readdir-with-fatfs branch May 18, 2026 12:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants