From 78c810376e52b551b1206628d46afb0274aab9e6 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Deuc=D0=B5?= <shurd@sasktel.net>
Date: Tue, 5 Mar 2024 14:58:20 -0500
Subject: [PATCH] Don't return an error when reading /..

POSIX requires a .. directory in the root of a filesystem, and
some SFTP clients (at least Filezilla and WinSCP) assume it's there
even if the remote doesn't list it.  Per POSIX, /. and /.. are the
same directory.
---
 src/sbbs3/sftp.cpp | 9 +++------
 1 file changed, 3 insertions(+), 6 deletions(-)

diff --git a/src/sbbs3/sftp.cpp b/src/sbbs3/sftp.cpp
index a3a3934ff0..04529b1b97 100644
--- a/src/sbbs3/sftp.cpp
+++ b/src/sbbs3/sftp.cpp
@@ -731,13 +731,10 @@ sftp_resolve_path(char *target, const char *path, size_t size)
 			else if(*(out+1)=='.' && *(out+2)=='.' && (*(out+3)=='/' || *(out+3)==0))  {
 				*out=0;
 				p=strrchr(target,'/');
-				if(p==NULL) {
-					if (target_alloced)
-						free(target);
-					return nullptr;
+				if (p!=NULL) {
+					memmove(p,out+3,strlen(out+3)+1);
+					out=p;
 				}
-				memmove(p,out+3,strlen(out+3)+1);
-				out=p;
 			}
 			else  {
 				out++;
-- 
GitLab