From owner-svn-src-head@freebsd.org Sun Nov 19 20:13:12 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 93C66DBD8A6; Sun, 19 Nov 2017 20:13:12 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 5FDD4378A; Sun, 19 Nov 2017 20:13:12 +0000 (UTC) (envelope-from avos@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id vAJKDBVT037736; Sun, 19 Nov 2017 20:13:11 GMT (envelope-from avos@FreeBSD.org) Received: (from avos@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id vAJKDBbe037735; Sun, 19 Nov 2017 20:13:11 GMT (envelope-from avos@FreeBSD.org) Message-Id: <201711192013.vAJKDBbe037735@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: avos set sender to avos@FreeBSD.org using -f From: Andriy Voskoboinyk Date: Sun, 19 Nov 2017 20:13:11 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r326000 - head/usr.sbin/wlandebug X-SVN-Group: head X-SVN-Commit-Author: avos X-SVN-Commit-Paths: head/usr.sbin/wlandebug X-SVN-Commit-Revision: 326000 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.25 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 19 Nov 2017 20:13:12 -0000 Author: avos Date: Sun Nov 19 20:13:11 2017 New Revision: 326000 URL: https://svnweb.freebsd.org/changeset/base/326000 Log: wlandebug(8): allow fallback to old behavior + improve name checks. - Treat passed interface name as original if ifconfig_get_orig_name() fails. - Reject interface name if it does not start from "wlan". Modified: head/usr.sbin/wlandebug/wlandebug.c Modified: head/usr.sbin/wlandebug/wlandebug.c ============================================================================== --- head/usr.sbin/wlandebug/wlandebug.c Sun Nov 19 12:36:03 2017 (r325999) +++ head/usr.sbin/wlandebug/wlandebug.c Sun Nov 19 20:13:11 2017 (r326000) @@ -169,15 +169,19 @@ get_orig_iface_name(char *oid, size_t oid_size, char * char *orig_name; h = ifconfig_open(); - if (ifconfig_get_orig_name(h, name, &orig_name) < 0) - errc(1, ifconfig_err_errno(h), "cannot get interface name"); + if (ifconfig_get_orig_name(h, name, &orig_name) < 0) { + /* check for original interface name. */ + orig_name = name; + } - if (strlen(orig_name) < strlen("wlan") + 1) + if (strlen(orig_name) < strlen("wlan") + 1 || + strncmp(orig_name, "wlan", 4) != 0) errx(1, "expecting a wlan interface name"); ifconfig_close(h); setoid(oid, oid_size, orig_name); - free(orig_name); + if (orig_name != name) + free(orig_name); } int