From 8091d334a33faf98954a7240adf4bd1810383a4e Mon Sep 17 00:00:00 2001
From: David Lawrence Ramsey <pooka109@gmail.com>
Date: Tue, 16 Nov 2004 02:23:10 +0000
Subject: [PATCH] add Ulf Harnhammar's input_tab() segfault fix

git-svn-id: svn://svn.savannah.gnu.org/nano/trunk/nano@2101 35c25a1d-7b9e-4130-9fde-d3aeb78583b8
---
 ChangeLog   | 3 +++
 src/files.c | 2 +-
 2 files changed, 4 insertions(+), 1 deletion(-)

diff --git a/ChangeLog b/ChangeLog
index 4bd7e0c2..623f9fc9 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -173,6 +173,9 @@ CVS code -
   open_prevfile(), open_nextfile()
 	- Translate the "New Buffer" string when displaying "Switched
 	  to" messages on the statusbar. (DLR)
+  input_tab()
+	- Fix snprintf() call so that we don't segfault when trying to
+	  complete a filename containing %'s. (Ulf Harnhammar)
 - global.c:
   shortcut_init()
 	- Remove redundant NANO_SMALL #ifdef. (DLR)
diff --git a/src/files.c b/src/files.c
index 4c82c952..ed37ac3c 100644
--- a/src/files.c
+++ b/src/files.c
@@ -2406,7 +2406,7 @@ char *input_tab(char *buf, int place, bool *lastwastab, int *newplace,
 
 		/* make each filename shown be the same length as the
 		   longest filename, with two spaces at the end */
-		snprintf(foo, longestname + 1, matches[i]);
+		snprintf(foo, longestname + 1, "%s", matches[i]);
 		while (strlen(foo) < longestname)
 		    strcat(foo, " ");
 
-- 
GitLab