Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/sys/dev/ic Apply FreeBSD r357300:



details:   https://anonhg.NetBSD.org/src/rev/c30639b5a097
branches:  trunk
changeset: 969117:c30639b5a097
user:      msaitoh <msaitoh%NetBSD.org@localhost>
date:      Sat Feb 08 08:23:01 2020 +0000

description:
Apply FreeBSD r357300:

 > aic7xxx(4): Fix unintended sign extension in ahd_inq()
 >
 > ahd_inb() returns type uint8_t.  The shift left by untyped 24 implicitly
 > promotes the result to type (signed) int.  Then the binary OR with uint64_t
 > values sign-extends the integer.  If bit 31 of the read value happened to be
 > set, the 64-bit result would have all upper 32 bits set to 1 due to OR.
 > This is clearly not intended.
 >
 > Reported by: Coverity
 > CID:         980473 (old one!)

diffstat:

 sys/dev/ic/aic79xx_inline.h |  4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diffs (18 lines):

diff -r d5222690cc2b -r c30639b5a097 sys/dev/ic/aic79xx_inline.h
--- a/sys/dev/ic/aic79xx_inline.h       Sat Feb 08 08:18:06 2020 +0000
+++ b/sys/dev/ic/aic79xx_inline.h       Sat Feb 08 08:23:01 2020 +0000
@@ -1,4 +1,4 @@
-/*     $NetBSD: aic79xx_inline.h,v 1.22 2013/04/27 13:25:09 kardel Exp $       */
+/*     $NetBSD: aic79xx_inline.h,v 1.23 2020/02/08 08:23:01 msaitoh Exp $      */
 
 /*
  * Inline routines shareable across OS platforms.
@@ -548,7 +548,7 @@
        return ((ahd_inb(ahd, port))
              | (ahd_inb(ahd, port+1) << 8)
              | (ahd_inb(ahd, port+2) << 16)
-             | (ahd_inb(ahd, port+3) << 24)
+             | (((uint64_t)ahd_inb(ahd, port+3)) << 24)
              | (((uint64_t)ahd_inb(ahd, port+4)) << 32)
              | (((uint64_t)ahd_inb(ahd, port+5)) << 40)
              | (((uint64_t)ahd_inb(ahd, port+6)) << 48)



Home | Main Index | Thread Index | Old Index