svn commit: r326000 - head/usr.sbin/wlandebug

Andriy Voskoboinyk avos at FreeBSD.org
Sun Nov 19 20:13:12 UTC 2017


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


More information about the svn-src-head mailing list