tool_parsecfg: detect and error on recursive --config use

The config file parser now has a maximum level of inclusions allowed (5)
to detect and prevent recursive inclusions of itself leading to badness.

Bonus: clean up return code handling from the config parser.

Test 774 verifies
Closes #19168
This commit is contained in:
Daniel Stenberg 2025-10-20 22:46:56 +02:00
parent b4f57c8045
commit 9e198618de
No known key found for this signature in database
GPG key ID: 5CC908FDB71E12C2
10 changed files with 72 additions and 32 deletions

View file

@ -110,7 +110,7 @@ test736 test737 test738 test739 test740 test741 test742 test743 test744 \
test745 test746 test747 test748 test749 test750 test751 test752 test753 \
test754 test755 test756 test757 test758 test759 test760 test761 test762 \
test763 test764 test765 test766 test767 test768 test769 test770 test771 \
test772 test773 \
test772 test773 test774 \
test780 test781 test782 test783 test784 test785 test786 test787 test788 \
test789 test790 test791 test792 test793 test794 test796 test797 \
\

View file

@ -30,7 +30,7 @@ config file with overly long option
<verify>
# the used option in the config file is too long
<errorcode>
26
2
</errorcode>
</verify>
</testcase>

View file

@ -30,7 +30,7 @@ http://%HOSTIP:%HTTPPORT/%TESTNUMBER -K %LOGDIR/cmd
# Verify data after the test has been "shot"
<verify>
<errorcode>
26
2
</errorcode>
</verify>
</testcase>

25
tests/data/test774 Normal file
View file

@ -0,0 +1,25 @@
<testcase>
<info>
<keywords>
--config
</keywords>
</info>
<client>
<name>
config file recursively including itself
</name>
<file name="%LOGDIR/cmd">
--config %LOGDIR/cmd
</file>
<command>
http://%HOSTIP:%HTTPPORT/ -K %LOGDIR/cmd
</command>
</client>
<verify>
<errorcode>
2
</errorcode>
</verify>
</testcase>