tool_urlglob: handle a zero length glob piece

Follow-up to 034612cd51

Add test 759 to verify

Reported-by: Stanislav Osipov
Fixes #18352
Closes #18353
This commit is contained in:
Daniel Stenberg 2025-08-22 13:30:30 +02:00
parent 80c10c5d5d
commit 33572b851e
No known key found for this signature in database
GPG Key ID: 5CC908FDB71E12C2
3 changed files with 33 additions and 2 deletions

View File

@ -142,7 +142,8 @@ static CURLcode glob_set(struct URLGlob *glob, const char **patternp,
if(!pat->c.set.elem)
return globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY);
pat->c.set.elem[pat->c.set.size] = strdup(curlx_dyn_ptr(&glob->buf));
pat->c.set.elem[pat->c.set.size] = strdup(curlx_dyn_ptr(&glob->buf) ?
curlx_dyn_ptr(&glob->buf): "");
if(!pat->c.set.elem[pat->c.set.size])
return globerror(glob, NULL, 0, CURLE_OUT_OF_MEMORY);
++pat->c.set.size;

View File

@ -108,7 +108,7 @@ test718 test719 test720 test721 test722 test723 test724 test725 test726 \
test727 test728 test729 test730 test731 test732 test733 test734 test735 \
test736 test737 test738 test739 test740 test741 test742 test743 test744 \
test745 test746 test747 test748 test749 test750 test751 test752 test753 \
test754 test755 test756 test757 test758 \
test754 test755 test756 test757 test758 test759 \
test780 test781 test782 test783 test784 test785 test786 test787 test788 \
test789 test790 test791 test792 test793 test794 test795 test796 test797 \
\

30
tests/data/test759 Normal file
View File

@ -0,0 +1,30 @@
<testcase>
<info>
<keywords>
globbing
</keywords>
</info>
#
# Client-side
<client>
<server>
none
</server>
<name>
glob '{,'
</name>
<command>
"{,,,,,,,}" "{," "{,,,"
</command>
</client>
#
# Verify data after the test has been "shot"
<verify>
# curl: (3) unmatched brace in URL position 1:
<errorcode>
3
</errorcode>
</verify>
</testcase>