Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep trailing delimiter with SFTP open #743

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

JacobBarthelmeh
Copy link
Contributor

@JacobBarthelmeh JacobBarthelmeh commented Sep 30, 2024

ZD 18566

Fix for SFTP cases with trailing delimiter.

OpenSSH client 9.6 (which does a SFTP command instead of SCP, -O restores using SCP protocol)

mkdir /tmp/subfolder
scp /tmp/test.txt [email protected]:/tmp/subfolder/test/

Before this change wolfSSH would allow test.txt to be copied to /tmp/subfolder/test. After this change the command correctly fails.

@JacobBarthelmeh JacobBarthelmeh self-assigned this Sep 30, 2024
@JacobBarthelmeh JacobBarthelmeh changed the title keep trailing delimiter with SFTP path clean keep trailing delimiter with SFTP open Oct 4, 2024
src/internal.c Outdated
out[0] = '/';
curSz++;
}
out[curSz] = 0;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

sanity checks needed on curSz before use (thanks @douzzer )

Comment on lines +15729 to +15738
if (!WOLFSSH_SFTP_IS_DELIM(out[0])) {
if (curSz + 1 < *outSz) {
WMEMMOVE(out+1, out, curSz);
out[0] = '/';
}
curSz++;
}
if (curSz < *outSz) {
out[curSz] = 0;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

As discussed, when *outSz is to small to accommodate the shifted data with the terminating null, an error code should be returned, and checked for by callers.

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.

3 participants