SFTP's handling of "." and ".."
Andrew Wood
andrew1tree at gmail.com
Fri Jul 4 08:01:24 AEST 2025
Hi all,
Apologies if this has already been discussed before; I googled a bit before
coming here but couldn't find any mention of this issue. The other day I
noticed what felt like some strange behavior from SFTP. When doing a
recursive put command to upload a directory and making the folder a "." or
"..", it gets copied to the destination with those dots. I'm not good at
explaining things so perhaps it's easier to give an example.
If I ran:
$ cd /path/to/source_dir
$ sftp dest_host
sftp> put -r . /destination/path
Instead of transferring source_dir as a full directory to
"/destination/path/source_dir", what happens is the "." is simply appended
to /destination/path resulting in all of the files going to
"/destination/path/.". Even worse, if I tried to transfer ".." to
"/destination/path", all my files would instead go to "/destination"!
This feels problematic to me because it's completely unexpected behavior
from what one would expect based on any other scenario when uploading a
directory. I think I found where in sftp.c this is happening:
[image: image.png]
So my question now is, would there be interest in me submitting a pull
request for a fix to this? Or am I completely missing something? Don't want
to waste any effort/waste any reviewer's time if this is intentional or
something that should be expected :)
Thanks,
Andrew
More information about the openssh-unix-dev
mailing list