Date: Wed, 25 May 2016 15:49:29 +0000 (UTC) From: Don Lewis <truckman@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r300686 - head/sbin/camcontrol Message-ID: <201605251549.u4PFnTkp079365@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: truckman Date: Wed May 25 15:49:29 2016 New Revision: 300686 URL: https://svnweb.freebsd.org/changeset/base/300686 Log: Fix a couple of Coverity Unintended sign extension sign extension defects. When shifting an unsigned byte into the upper 8 bits of an int and the resulting value is greater than 0x7FFFFFF, the result will be sign extended when converting to a 64 bit unsigned long. Fix by casting to (uint64_t) before the shift. Reported by: Coverity CID: 1356044, 1356045 Reviewed by: ken Modified: head/sbin/camcontrol/camcontrol.c Modified: head/sbin/camcontrol/camcontrol.c ============================================================================== --- head/sbin/camcontrol/camcontrol.c Wed May 25 15:43:01 2016 (r300685) +++ head/sbin/camcontrol/camcontrol.c Wed May 25 15:49:29 2016 (r300686) @@ -5188,7 +5188,7 @@ get_ata_status(struct cam_device *dev, u desc->count_7_0; *lba = ((uint64_t)desc->lba_47_40 << 40) | ((uint64_t)desc->lba_39_32 << 32) | - (desc->lba_31_24 << 24) | + ((uint64_t)desc->lba_31_24 << 24) | (desc->lba_23_16 << 16) | (desc->lba_15_8 << 8) | desc->lba_7_0; @@ -5249,7 +5249,7 @@ get_ata_status(struct cam_device *dev, u (res->lba_low); if (res->flags & CAM_ATAIO_48BIT) { *count |= (res->sector_count_exp << 8); - *lba |= (res->lba_low_exp << 24) | + *lba |= ((uint64_t)res->lba_low_exp << 24) | ((uint64_t)res->lba_mid_exp << 32) | ((uint64_t)res->lba_high_exp << 40); } else {
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201605251549.u4PFnTkp079365>