Print this page
11416 smbios_info_slot_peers() gets NULL check wrong

*** 19,29 **** * CDDL HEADER END */ /* * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. ! * Copyright (c) 2018, Joyent, Inc. * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /* --- 19,29 ---- * CDDL HEADER END */ /* * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. ! * Copyright 2019 Joyent, Inc. * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /*
*** 696,713 **** int smbios_info_slot_peers(smbios_hdl_t *shp, id_t id, uint_t *npeers, smbios_slot_peer_t **peerp) { const smb_struct_t *stp = smb_lookup_id(shp, id); ! const smb_slot_t *slotp = (const smb_slot_t *)stp->smbst_hdr; smbios_slot_peer_t *peer; size_t minlen; uint_t i; if (stp == NULL) return (-1); /* errno is set for us */ if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT) return (smb_set_errno(shp, ESMB_TYPE)); if (stp->smbst_hdr->smbh_len <= offsetof(smb_slot_t, smbsl_npeers) || slotp->smbsl_npeers == 0) { --- 696,715 ---- int smbios_info_slot_peers(smbios_hdl_t *shp, id_t id, uint_t *npeers, smbios_slot_peer_t **peerp) { const smb_struct_t *stp = smb_lookup_id(shp, id); ! const smb_slot_t *slotp; smbios_slot_peer_t *peer; size_t minlen; uint_t i; if (stp == NULL) return (-1); /* errno is set for us */ + slotp = (const smb_slot_t *)stp->smbst_hdr; + if (stp->smbst_hdr->smbh_type != SMB_TYPE_SLOT) return (smb_set_errno(shp, ESMB_TYPE)); if (stp->smbst_hdr->smbh_len <= offsetof(smb_slot_t, smbsl_npeers) || slotp->smbsl_npeers == 0) {