NetBSD-Bugs archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: bin/57392: wgconfig add peer accepts anything for options
The following reply was made to PR bin/57392; it has been noted by GNATS.
From: David Holland <dholland-bugs%netbsd.org@localhost>
To: gnats-bugs%netbsd.org@localhost
Cc:
Subject: Re: bin/57392: wgconfig add peer accepts anything for options
Date: Sun, 7 May 2023 06:26:30 +0000
On Sat, May 06, 2023 at 03:20:00AM +0000, oster%netbsd.org@localhost wrote:
> Perhaps something like this?
>
> *** wgconfig.c.orig 2023-05-04 16:35:04.400335580 -0600
> --- wgconfig.c 2023-05-05 19:27:42.055900579 -0600
> ***************
> *** 680,693 ****
> --- 680,697 ----
> {
>
> while (argc > 0) {
> + int found = 0;
> for (size_t i = 0; i < __arraycount(options); i++) {
> const struct option *opt = &options[i];
> size_t optlen = strlen(opt->option);
> if (strncmp(argv[0], opt->option, optlen) == 0) {
> opt->func(argv[0] + optlen, prop_dict);
> + found = 1;
> break;
> }
> }
> + if (found == 0)
> + errx(EXIT_FAILURE, "invalid option: %s", argv[0]);
> argc -= 1;
> argv += 1;
> }
Any reason to not just commit that?
--
David A. Holland
dholland%netbsd.org@localhost
Home |
Main Index |
Thread Index |
Old Index