summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAndrei Pavel <andrei@isc.org>2023-12-15 11:36:24 +0100
committerAndrei Pavel <andrei@isc.org>2024-01-26 18:47:41 +0100
commitc3507ebf21a86c84194beb6200bd865205b674fe (patch)
tree370ab852f19c9ee7ae527262d45d72fde06f8314 /src
parent[#2788] exhaust options before throwing error (diff)
downloadkea-c3507ebf21a86c84194beb6200bd865205b674fe.tar.xz
kea-c3507ebf21a86c84194beb6200bd865205b674fe.zip
[#2788] reset optarg
optarg is not reset in musl's getopt and it leaks values to other flags. Reset it for all systems because it cannot hurt. If you remove the optarg reset, you should see the bug in action on alpine systems in DstubControllerTest.commandLineArgs when parsing argv2: ``` [ RUN ] DStubControllerTest.commandLineArgs d_controller_unittests.cc:102: Failure Expected equality of these values: std::string(ex.what()) Which is: "unsupported option: -b cfgName" "unsupported option: -b" [ FAILED ] DStubControllerTest.commandLineArgs (14 ms) ```
Diffstat (limited to 'src')
-rw-r--r--src/lib/process/d_controller.cc1
1 files changed, 1 insertions, 0 deletions
diff --git a/src/lib/process/d_controller.cc b/src/lib/process/d_controller.cc
index e8d72d5f2e..f08794a9c3 100644
--- a/src/lib/process/d_controller.cc
+++ b/src/lib/process/d_controller.cc
@@ -250,6 +250,7 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
// ("c" or "d") handle it here. If its a valid custom option, then
// invoke customOption.
int ch;
+ optarg = 0;
opterr = 0;
optind = 1;
std::string opts("dvVWc:t:" + getCustomOpts());