Skip to content

Commit

Permalink
Fix the getopt_long() argument
Browse files Browse the repository at this point in the history
The argument `longopts` of `getopt_long()` is:
	struct option {
            const char *name;
	    int         has_arg;
	    int        *flag;
	    int         val;
	};

The last field `val` does NOT hold the short version of the option, it
is the value to return, or to load into the variable pointed to by flag.
  • Loading branch information
DimitriPapadopoulos committed Nov 5, 2023
1 parent 784b555 commit 4ae6e53
Showing 1 changed file with 7 additions and 7 deletions.
14 changes: 7 additions & 7 deletions src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -271,16 +271,16 @@ int main(int argc, char **argv)
struct vpn_config cli_cfg = invalid_cfg;

const struct option long_options[] = {
{"help", no_argument, NULL, 'h'},
{"help", no_argument, NULL, 0},
{"version", no_argument, NULL, 0},
{"config", required_argument, NULL, 'c'},
{"config", required_argument, NULL, 0},
{"pinentry", required_argument, NULL, 0},
{"realm", required_argument, NULL, 0},
{"username", required_argument, NULL, 'u'},
{"password", required_argument, NULL, 'p'},
{"username", required_argument, NULL, 0},
{"password", required_argument, NULL, 0},
{"cookie", required_argument, NULL, 0},
{"cookie-on-stdin", no_argument, NULL, 0},
{"otp", required_argument, NULL, 'o'},
{"otp", required_argument, NULL, 0},
{"otp-prompt", required_argument, NULL, 0},
{"otp-delay", required_argument, NULL, 0},
{"no-ftm-push", no_argument, &cli_cfg.no_ftm_push, 1},
Expand Down Expand Up @@ -313,10 +313,10 @@ int main(int argc, char **argv)
{"plugin", required_argument, NULL, 0}, // deprecated
#endif
#if HAVE_USR_SBIN_PPP
{"ppp-system", required_argument, NULL, 0},
{"ppp-system", required_argument, NULL, 0},
#endif
#if HAVE_RESOLVCONF
{"use-resolvconf", required_argument, NULL, 0},
{"use-resolvconf", required_argument, NULL, 0},
#endif
{NULL, 0, NULL, 0}
};
Expand Down

0 comments on commit 4ae6e53

Please sign in to comment.