Source-Changes-HG archive

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

[src/netbsd-10]: src/usr.sbin/wgconfig Pull up following revision(s) (request...



details:   https://anonhg.NetBSD.org/src/rev/556f878a128d
branches:  netbsd-10
changeset: 376326:556f878a128d
user:      martin <martin%NetBSD.org@localhost>
date:      Thu Jun 08 11:12:22 2023 +0000

description:
Pull up following revision(s) (requested by oster in ticket #194):

        usr.sbin/wgconfig/wgconfig.c: revision 1.6

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 8caa26a57afe -r 556f878a128d usr.sbin/wgconfig/wgconfig.c
--- a/usr.sbin/wgconfig/wgconfig.c      Sat Jun 03 15:33:41 2023 +0000
+++ b/usr.sbin/wgconfig/wgconfig.c      Thu Jun 08 11:12:22 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.5.6.1 2023/06/08 11:12:22 martin 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.5.6.1 2023/06/08 11:12:22 martin 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