[openssh-commits] [openssh] 02/03: upstream: avoid a fatal() when sftp tab-completes filenames that

git+noreply at mindrot.org git+noreply at mindrot.org
Tue Sep 30 10:58:45 AEST 2025


This is an automated email from the git hooks/post-receive script.

djm pushed a commit to branch master
in repository openssh.

commit 1f7556753869654ba5e2bf61e384c5da2db5ca6a
Author: djm at openbsd.org <djm at openbsd.org>
AuthorDate: Tue Sep 30 00:06:06 2025 +0000

    upstream: avoid a fatal() when sftp tab-completes filenames that
    
    share common utf-8 characters that don't encode to a complete codepoint
    
    from menthu.zhou via GHPR#587; ok dtucker@
    
    OpenBSD-Commit-ID: e07e4d8a8cac032ab536570b8214e6ef6839b585
---
 sftp.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/sftp.c b/sftp.c
index c77a608a8..bdcf97708 100644
--- a/sftp.c
+++ b/sftp.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: sftp.c,v 1.243 2025/09/25 06:23:19 jsg Exp $ */
+/* $OpenBSD: sftp.c,v 1.244 2025/09/30 00:06:06 djm Exp $ */
 /*
  * Copyright (c) 2001-2004 Damien Miller <djm at openbsd.org>
  *
@@ -1868,6 +1868,7 @@ complete_ambiguous(const char *word, char **list, size_t count)
 
 	if (count > 0) {
 		u_int y, matchlen = strlen(list[0]);
+		u_int itemlen = matchlen, wordlen = strlen(word);
 
 		/* Find length of common stem */
 		for (y = 1; list[y]; y++) {
@@ -1880,6 +1881,10 @@ complete_ambiguous(const char *word, char **list, size_t count)
 			matchlen = x;
 		}
 
+		for (; matchlen > wordlen; matchlen--)
+			if (mblen(list[0] + matchlen, itemlen - matchlen) >= 0)
+				break;
+
 		if (matchlen > strlen(word)) {
 			char *tmp = xstrdup(list[0]);
 

-- 
To stop receiving notification emails like this one, please contact
djm at mindrot.org.


More information about the openssh-commits mailing list