bug-bash
[Top][All Lists]
Advanced

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

[PATCH] rl_tilde_expand: avoid uninitialized memory use


From: Grisha Levit
Subject: [PATCH] rl_tilde_expand: avoid uninitialized memory use
Date: Fri, 18 Oct 2024 01:14:45 -0400

    $ bash --norc -in <<< $'\e&'

    WARNING: MemorySanitizer: use-of-uninitialized-value
    #0 rl_tilde_expand lib/readline/util.c:208:10
---
 lib/readline/util.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/readline/util.c b/lib/readline/util.c
index 2bcc776a..d03c899e 100644
--- a/lib/readline/util.c
+++ b/lib/readline/util.c
@@ -205,9 +205,9 @@ rl_tilde_expand (int ignore, int key)
   end = start;
   do
     end++;
-  while (whitespace (rl_line_buffer[end]) == 0 && end < rl_end);
+  while (end < rl_end && whitespace (rl_line_buffer[end]) == 0);
 
-  if (whitespace (rl_line_buffer[end]) || end >= rl_end)
+  if (end >= rl_end || whitespace (rl_line_buffer[end]))
     end--;
 
   /* If the first character of the current word is a tilde, perform
-- 
2.47.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]