summaryrefslogtreecommitdiffstats
path: root/sbin/etherswitchcfg
diff options
context:
space:
mode:
authorloos <loos@FreeBSD.org>2014-07-05 20:16:02 +0000
committerloos <loos@FreeBSD.org>2014-07-05 20:16:02 +0000
commitf995552a764a2c98cd7a2221aee581a0e5198186 (patch)
tree40fec5df2470ffcc4455887684b61029fd87f454 /sbin/etherswitchcfg
parentc5e392f88d5591c4d92dbc05e224ec98ddb1d609 (diff)
downloadFreeBSD-src-f995552a764a2c98cd7a2221aee581a0e5198186.zip
FreeBSD-src-f995552a764a2c98cd7a2221aee581a0e5198186.tar.gz
Check the number of returned entries before doing any access to ifm_ulist.
Diffstat (limited to 'sbin/etherswitchcfg')
-rw-r--r--sbin/etherswitchcfg/etherswitchcfg.c2
1 files changed, 2 insertions, 0 deletions
diff --git a/sbin/etherswitchcfg/etherswitchcfg.c b/sbin/etherswitchcfg/etherswitchcfg.c
index dd68e67..f7f117a 100644
--- a/sbin/etherswitchcfg/etherswitchcfg.c
+++ b/sbin/etherswitchcfg/etherswitchcfg.c
@@ -235,6 +235,8 @@ set_port_media(struct cfg *cfg, char *argv[])
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;
OpenPOWER on IntegriCloud