Print this page
10145 smbios_info_boot() gets NULL check wrong

*** 19,29 **** * CDDL HEADER END */ /* * Copyright 2015 OmniTI Computer Consulting, Inc. All rights reserved. ! * Copyright (c) 2017, 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 (c) 2018, Joyent, Inc. * Copyright 2010 Sun Microsystems, Inc. All rights reserved. * Use is subject to license terms. */ /*
*** 981,997 **** id_t smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp) { const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT); ! const smb_boot_t *b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr; if (stp == NULL) return (-1); /* errno is set for us */ bzero(bp, sizeof (smbios_boot_t)); bp->smbt_status = b->smbbo_status[0]; bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t); bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL; return (stp->smbst_hdr->smbh_hdl); --- 981,999 ---- id_t smbios_info_boot(smbios_hdl_t *shp, smbios_boot_t *bp) { const smb_struct_t *stp = smb_lookup_type(shp, SMB_TYPE_BOOT); ! const smb_boot_t *b; if (stp == NULL) return (-1); /* errno is set for us */ bzero(bp, sizeof (smbios_boot_t)); + b = (smb_boot_t *)(uintptr_t)stp->smbst_hdr; + bp->smbt_status = b->smbbo_status[0]; bp->smbt_size = stp->smbst_hdr->smbh_len - sizeof (smb_boot_t); bp->smbt_data = bp->smbt_size ? &b->smbbo_status[1] : NULL; return (stp->smbst_hdr->smbh_hdl);