Module Name:    src
Committed By:   oster
Date:           Sun May  7 16:05:07 UTC 2023

Modified Files:
        src/usr.sbin/wgconfig: wgconfig.c

Log Message:
Don't allow "wgconfig add peer ..." to accept invalid options.

Addresses PR bin/57392 .


To generate a diff of this commit:
cvs rdiff -u -r1.5 -r1.6 src/usr.sbin/wgconfig/wgconfig.c

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/usr.sbin/wgconfig/wgconfig.c
diff -u src/usr.sbin/wgconfig/wgconfig.c:1.5 src/usr.sbin/wgconfig/wgconfig.c:1.6
--- src/usr.sbin/wgconfig/wgconfig.c:1.5	Fri Aug 28 17:17:53 2020
+++ src/usr.sbin/wgconfig/wgconfig.c	Sun May  7 16:05:07 2023
@@ -1,4 +1,4 @@
-/*	$NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $	*/
+/*	$NetBSD: wgconfig.c,v 1.6 2023/05/07 16:05:07 oster Exp $	*/
 
 /*
  * Copyright (C) Ryota Ozaki <ozaki.ry...@gmail.com>
@@ -30,7 +30,7 @@
  */
 
 #include <sys/cdefs.h>
-__RCSID("$NetBSD: wgconfig.c,v 1.5 2020/08/28 17:17:53 tih Exp $");
+__RCSID("$NetBSD: wgconfig.c,v 1.6 2023/05/07 16:05:07 oster Exp $");
 
 #include <sys/ioctl.h>
 
@@ -680,14 +680,18 @@ handle_options(int argc, char *argv[], p
 {
 
 	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;
 	}

Reply via email to