]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC r337456:
authorpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 22 Aug 2018 04:21:25 +0000 (04:21 +0000)
committerpfg <pfg@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Wed, 22 Aug 2018 04:21:25 +0000 (04:21 +0000)
commit8300e60f6b7a5c833375eee08b4a4b798faaabf9
tree076e331f546ae6968fd570ffb6cb21ef45053e8f
parent67aa3ef0d82806304a85239b7b8de205dce6c6cd
MFC r337456:
msdosfs: fixes for Undefined Behavior.

These were found by the Undefined Behaviour GsoC project at NetBSD:

Do not change signedness bit with left shift.
While there avoid signed integer overflow.
Address both issues with using unsigned type.

msdosfs_fat.c:512:42, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:521:44, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:744:14, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:744:24, signed integer overflow: -2147483648 - 1 cannot be
represented in type 'int [20]'
msdosfs_fat.c:840:13, left shift of 1 by 31 places cannot be represented
in type 'int'
msdosfs_fat.c:840:36, signed integer overflow: -2147483648 - 1 cannot be
represented in type 'int [20]'

Detected with micro-UBSan in the user mode.

Hinted from: NetBSD (CVS 1.33)

git-svn-id: svn://svn.freebsd.org/base/stable/10@338180 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
sys/fs/msdosfs/msdosfs_fat.c