Check the number of returned entries before doing any access to ifm_ulist.

This commit is contained in:
Luiz Otavio O Souza 2014-07-05 20:16:02 +00:00
parent 9f65e34ff8
commit a48d677f26

View File

@ -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;