Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: libedit



On Wed, Oct 09, 2019 at 11:11:54AM +0100, Patrick Welche wrote:
> On Wed, Oct 09, 2019 at 10:52:54AM +0100, Patrick Welche wrote:
> > here seems to be some sort of out by one error (/bin/sh):
> > 
> > cd Ne[tab] -> cd NetBS
> > 
> > That wasn't the case before this morning's update...
> 
> Trivial fix on the way: 
> 
> The stpncpy() and strncpy() functions copy at most len characters
> The strlcpy() function copies up to size - 1 characters

This fixes it, but seems to defeat the point of using strlcpy - rather
leave as strncpy?

Cheers,

Patrick
Index: filecomplete.c
===================================================================
RCS file: /cvsroot/src/lib/libedit/filecomplete.c,v
retrieving revision 1.60
diff -u -r1.60 filecomplete.c
--- filecomplete.c	8 Oct 2019 19:21:40 -0000	1.60
+++ filecomplete.c	9 Oct 2019 10:19:36 -0000
@@ -507,7 +507,7 @@
 		el_free(match_list);
 		return NULL;
 	}
-	(void)strlcpy(retstr, match_list[1], max_equal);
+	(void)strlcpy(retstr, match_list[1], max_equal + 1);
 	match_list[0] = retstr;
 
 	/* add NULL as last pointer to the array */


Home | Main Index | Thread Index | Old Index