]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/commit
MFC r337422:
authorpfg <pfg@FreeBSD.org>
Tue, 21 Aug 2018 01:17:28 +0000 (01:17 +0000)
committerpfg <pfg@FreeBSD.org>
Tue, 21 Aug 2018 01:17:28 +0000 (01:17 +0000)
commita637c8386f0522f1b253ba58f497f31ac4fa981a
tree75f0726c6b34386571951b246a09766d51301c19
parent155ce04e96f1bde7d7b68a1fd9c39fc9f29abd10
MFC r337422:
libc: fix cases of undefined behavior.

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

Avoid undefined behavior in ftok(3)

Do not change the signedness bit with a left shift operation.
Cast to unsigned integer to prevent this.

ftok.c:56:10, left shift of 123456789 by 24 places cannot be represented
in type 'int'
ftok.c:56:10, left shift of 4160 by 24 places cannot be represented in
type 'int'

Avoid undefined behavior in an inet_addr.c

Do not change the signedness bit with a left shift operation.
Cast to unsigned integer to prevent this.

inet_addr.c:218:20, left shift of 131 by 24 places cannot be represented
in type 'int'

Detected with micro-UBSan in the user mode.

Obtained from: NetBSD
lib/libc/gen/ftok.c
lib/libc/inet/inet_addr.c