66 lines
1.6 KiB
Diff
66 lines
1.6 KiB
Diff
diff -up less-590/prompt.c.cve2024_32487regrfix less-590/prompt.c
|
|
--- less-590/prompt.c.cve2024_32487regrfix 2024-08-06 21:43:33.716058700 +0200
|
|
+++ less-590/prompt.c 2024-08-06 21:48:58.264708406 +0200
|
|
@@ -86,17 +86,30 @@ init_prompt(VOID_PARAM)
|
|
|
|
/*
|
|
* Append a string to the end of the message.
|
|
+ * nprt means the character *may* be nonprintable
|
|
+ * and should be converted to printable form.
|
|
*/
|
|
- static void
|
|
-ap_str(s)
|
|
- char *s;
|
|
+static void ap_estr(char *s, lbool nprt)
|
|
{
|
|
constant char *es = s + strlen(s);
|
|
while (*s != '\0')
|
|
{
|
|
LWCHAR ch = step_char(&s, +1, es);
|
|
- constant char *ps = utf_mode ? prutfchar(ch) : prchar(ch);
|
|
- size_t plen = strlen(ps);
|
|
+ constant char *ps;
|
|
+ char ubuf[MAX_UTF_CHAR_LEN+1];
|
|
+ size_t plen;
|
|
+
|
|
+ if (nprt)
|
|
+ {
|
|
+ ps = utf_mode ? prutfchar(ch) : prchar(ch);
|
|
+ } else
|
|
+ {
|
|
+ char *up = ubuf;
|
|
+ put_wchar(&up, ch);
|
|
+ *up = '\0';
|
|
+ ps = ubuf;
|
|
+ }
|
|
+ plen = strlen(ps);
|
|
if (mp + plen >= message + PROMPT_SIZE)
|
|
break;
|
|
strcpy(mp, ps);
|
|
@@ -104,6 +117,12 @@ ap_str(s)
|
|
}
|
|
*mp = '\0';
|
|
}
|
|
+
|
|
+static void ap_str(char *s)
|
|
+{
|
|
+ ap_estr(s, FALSE);
|
|
+}
|
|
+
|
|
|
|
/*
|
|
* Append a character to the end of the message.
|
|
@@ -316,10 +335,10 @@ protochar(c, where, iseditproto)
|
|
break;
|
|
#endif
|
|
case 'f': /* File name */
|
|
- ap_str(get_filename(curr_ifile));
|
|
+ ap_estr(get_filename(curr_ifile), TRUE);
|
|
break;
|
|
case 'F': /* Last component of file name */
|
|
- ap_str(last_component(get_filename(curr_ifile)));
|
|
+ ap_estr(last_component(get_filename(curr_ifile)), TRUE);
|
|
break;
|
|
case 'g': /* Shell-escaped file name */
|
|
s = shell_quote(get_filename(curr_ifile));
|