Date: Mon, 9 Nov 2020 00:39:49 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-12@freebsd.org Subject: svn commit: r367504 - stable/12/sbin/ifconfig Message-ID: <202011090039.0A90dnCh085680@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: kib Date: Mon Nov 9 00:39:48 2020 New Revision: 367504 URL: https://svnweb.freebsd.org/changeset/base/367504 Log: MFC r367285: ifconfig: properly detect invalid mediaopt keywords. Modified: stable/12/sbin/ifconfig/ifmedia.c Directory Properties: stable/12/ (props changed) Modified: stable/12/sbin/ifconfig/ifmedia.c ============================================================================== --- stable/12/sbin/ifconfig/ifmedia.c Mon Nov 9 00:34:23 2020 (r367503) +++ stable/12/sbin/ifconfig/ifmedia.c Mon Nov 9 00:39:48 2020 (r367504) @@ -566,7 +566,7 @@ get_media_options(int type, const char *val) struct ifmedia_description *desc; struct ifmedia_type_to_subtype *ttos; char *optlist, *optptr; - int option = 0, i, rval = 0; + int option, i, rval = 0; /* We muck with the string, so copy it. */ optlist = strdup(val); @@ -587,12 +587,13 @@ get_media_options(int type, const char *val) */ optptr = optlist; for (; (optptr = strtok(optptr, ",")) != NULL; optptr = NULL) { + option = -1; for (i = 0; ttos->options[i].desc != NULL; i++) { option = lookup_media_word(ttos->options[i].desc, optptr); if (option != -1) break; } - if (option == 0) + if (option == -1) errx(1, "unknown option: %s", optptr); rval |= option; }
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202011090039.0A90dnCh085680>