Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/usr.sbin/wgconfig Don't allow "wgconfig add peer ..." to acc...



details:   https://anonhg.NetBSD.org/src/rev/a438e55e1049
branches:  trunk
changeset: 374596:a438e55e1049
user:      oster <oster%NetBSD.org@localhost>
date:      Sun May 07 16:05:07 2023 +0000

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

Addresses PR bin/57392 .

diffstat:

 usr.sbin/wgconfig/wgconfig.c |  8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diffs (37 lines):

diff -r 2692574eb8a8 -r a438e55e1049 usr.sbin/wgconfig/wgconfig.c
--- a/usr.sbin/wgconfig/wgconfig.c      Sun May 07 12:43:32 2023 +0000
+++ b/usr.sbin/wgconfig/wgconfig.c      Sun May 07 16:05:07 2023 +0000
@@ -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.ryota%gmail.com@localhost>
@@ -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;
        }



Home | Main Index | Thread Index | Old Index