report
After having been compared to a NULL value at `if (dest.data) {`, 
pointer 'dest.data' is passed in call to function 'o_addQchr' 
at `o_addQchr(&dest, ch);`, where it is dereferenced at ` && strchr("*?[-\\" 
MAYBE_BRACES, ch)`

Corrections explained:
Added a check before calling o_addQchr to ensure that dest.data is not NULL.
This prevents a possible segmentation fault when dest is initialized with 
NULL_O_STRING.

Changes:
- Added a NULL check before calling o_addQchr at hush.c:6470.

This fix ensures stability without modifying the function logic.
Triggers found by static analyzer Svace.

Signed-off-by: Anton Moryakov <[email protected]>
---
 shell/hush.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/shell/hush.c b/shell/hush.c
index 4a97293cc..44373d643 100644
--- a/shell/hush.c
+++ b/shell/hush.c
@@ -6500,7 +6500,8 @@ static NOINLINE int 
encode_then_append_var_plusminus(o_string *output, int n,
                         * x=x; echo ${x:+/bin/c*} - prints many filenames
                         * x=x; echo ${x:+"/bin/c*"} - prints: /bin/c*
                         */
-                       o_addQchr(&dest, ch);
+                       if(dest.data)
+                               o_addQchr(&dest, ch);
                }
        } /* for (;;) */
 
-- 
2.30.2

_______________________________________________
busybox mailing list
[email protected]
https://lists.busybox.net/mailman/listinfo/busybox

Reply via email to