Skip to content

Commit c3507eb

Browse files
committed
[#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) ```
1 parent 697e9fa commit c3507eb

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

src/lib/process/d_controller.cc

+1
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,7 @@ DControllerBase::parseArgs(int argc, char* argv[]) {
250250
// ("c" or "d") handle it here. If its a valid custom option, then
251251
// invoke customOption.
252252
int ch;
253+
optarg = 0;
253254
opterr = 0;
254255
optind = 1;
255256
std::string opts("dvVWc:t:" + getCustomOpts());

0 commit comments

Comments
 (0)