From owner-svn-src-head@FreeBSD.ORG Sat Jul 5 20:16:02 2014 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id DBFD5389; Sat, 5 Jul 2014 20:16:02 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::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 C91BC29EE; Sat, 5 Jul 2014 20:16:02 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s65KG2lL048928; Sat, 5 Jul 2014 20:16:02 GMT (envelope-from loos@svn.freebsd.org) Received: (from loos@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s65KG2gi048927; Sat, 5 Jul 2014 20:16:02 GMT (envelope-from loos@svn.freebsd.org) Message-Id: <201407052016.s65KG2gi048927@svn.freebsd.org> From: Luiz Otavio O Souza Date: Sat, 5 Jul 2014 20:16:02 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r268301 - head/sbin/etherswitchcfg X-SVN-Group: head 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.18 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: Sat, 05 Jul 2014 20:16:03 -0000 Author: loos Date: Sat Jul 5 20:16:02 2014 New Revision: 268301 URL: http://svnweb.freebsd.org/changeset/base/268301 Log: Check the number of returned entries before doing any access to ifm_ulist. Modified: head/sbin/etherswitchcfg/etherswitchcfg.c Modified: head/sbin/etherswitchcfg/etherswitchcfg.c ============================================================================== --- head/sbin/etherswitchcfg/etherswitchcfg.c Sat Jul 5 20:08:35 2014 (r268300) +++ head/sbin/etherswitchcfg/etherswitchcfg.c Sat Jul 5 20:16:02 2014 (r268301) @@ -235,6 +235,8 @@ set_port_media(struct cfg *cfg, char *ar p.es_ifmr.ifm_count = IFMEDIAREQ_NULISTENTRIES; if (ioctl(cfg->fd, IOETHERSWITCHGETPORT, &p) != 0) err(EX_OSERR, "ioctl(IOETHERSWITCHGETPORT)"); + if (p.es_ifmr.ifm_count == 0) + return; subtype = get_media_subtype(IFM_TYPE(ifm_ulist[0]), argv[1]); p.es_ifr.ifr_media = (p.es_ifmr.ifm_current & IFM_IMASK) | IFM_TYPE(ifm_ulist[0]) | subtype;