From a48d677f268433a839407df83dea02c34f221f05 Mon Sep 17 00:00:00 2001 From: Luiz Otavio O Souza Date: Sat, 5 Jul 2014 20:16:02 +0000 Subject: [PATCH] Check the number of returned entries before doing any access to ifm_ulist. --- sbin/etherswitchcfg/etherswitchcfg.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/sbin/etherswitchcfg/etherswitchcfg.c b/sbin/etherswitchcfg/etherswitchcfg.c index dd68e67c4ec9..f7f117ae3e2b 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;