about summary refs log tree commit diff
path: root/posix/wordexp-test.c
diff options
context:
space:
mode:
authorJulian Squires <julian@cipht.net>2023-03-22 14:09:57 -0230
committerAdhemerval Zanella <adhemerval.zanella@linaro.org>2023-03-28 10:12:12 -0300
commit31bfe3ef4ea898df606cb6cc59ac72de27002b01 (patch)
tree731aa1a7af0cc103912488faf36683a9e88ab4ac /posix/wordexp-test.c
parent07dd75589ecbedec5162a5645d57f8bd093a45db (diff)
downloadglibc-31bfe3ef4ea898df606cb6cc59ac72de27002b01.tar.gz
glibc-31bfe3ef4ea898df606cb6cc59ac72de27002b01.tar.xz
glibc-31bfe3ef4ea898df606cb6cc59ac72de27002b01.zip
posix: Fix some crashes in wordexp [BZ #18096]
Without these fixes, the first three included tests segfault (on a
NULL dereference); the fourth aborts on an assertion, which is itself
unnecessary.

Signed-off-by: Julian Squires <julian@cipht.net>
Reviewed-by: Adhemerval Zanella  <adhemerval.zanella@linaro.org>
Diffstat (limited to 'posix/wordexp-test.c')
-rw-r--r--posix/wordexp-test.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/posix/wordexp-test.c b/posix/wordexp-test.c
index f7a591149b..bae27d6cee 100644
--- a/posix/wordexp-test.c
+++ b/posix/wordexp-test.c
@@ -117,6 +117,8 @@ struct test_case_struct
     { 0, NULL, "$((010+0x10))", 0, 1, { "24" }, IFS },
     { 0, NULL, "$((-010+0x10))", 0, 1, { "8" }, IFS },
     { 0, NULL, "$((-0x10+010))", 0, 1, { "-8" }, IFS },
+    { 0, NULL, "$(())", 0, 1, { "0", }, IFS },
+    { 0, NULL, "$[]", 0, 1, { "0", }, IFS },
 
     /* Advanced parameter expansion */
     { 0, NULL, "${var:-bar}", 0, 1, { "bar", }, IFS },
@@ -138,6 +140,8 @@ struct test_case_struct
     { 0, "12345", "${#var}", 0, 1, { "5", }, IFS },
     { 0, NULL, "${var:-'}'}", 0, 1, { "}", }, IFS },
     { 0, NULL, "${var-}", 0, 0, { NULL }, IFS },
+    { 0, NULL, "${a?}", 0, 0, { NULL, }, IFS },
+    { 0, NULL, "${#a=}", 0, 1, { "0", }, IFS },
 
     { 0, "pizza", "${var#${var}}", 0, 0, { NULL }, IFS },
     { 0, "pepperoni", "${var%$(echo oni)}", 0, 1, { "pepper" }, IFS },