Reported by Jeffrey Walton <noloader@gmail.com>.
* lib/unictype/numeric.c (uc_numeric_value): Avoid undefined behaviour
on shift overflow, caught by "gcc -fsanitize=undefined".
* lib/unictype/bidi_of.c (uc_bidi_class): Add cast, for clarity.
* lib/unictype/categ_of.c (lookup_withtable): Likewise.
* lib/unictype/joininggroup_of.c (uc_joining_group): Likewise.
+2019-03-08 Bruno Haible <bruno@clisp.org>
+
+ unictype/numeric: Fix undefined behaviour.
+ Reported by Jeffrey Walton <noloader@gmail.com>.
+ * lib/unictype/numeric.c (uc_numeric_value): Avoid undefined behaviour
+ on shift overflow, caught by "gcc -fsanitize=undefined".
+ * lib/unictype/bidi_of.c (uc_bidi_class): Add cast, for clarity.
+ * lib/unictype/categ_of.c (lookup_withtable): Likewise.
+ * lib/unictype/joininggroup_of.c (uc_joining_group): Likewise.
+
2019-03-05 Paul Eggert <eggert@cs.ucla.edu>
git-version-gen: fix --version copyright year
unsigned int index3 = ((uc & bidi_category_header_4) + lookup2) * 5;
/* level3 contains 5-bit values, packed into 16-bit words. */
unsigned int lookup3 =
- ((u_bidi_category.level3[index3>>4]
+ (((unsigned int) u_bidi_category.level3[index3>>4]
| ((unsigned int) u_bidi_category.level3[(index3>>4)+1] << 16))
>> (index3 % 16))
& 0x1f;
unsigned int index3 = ((uc & category_header_4) + lookup2) * 5;
/* level3 contains 5-bit values, packed into 16-bit words. */
unsigned int lookup3 =
- ((u_category.level3[index3>>4]
+ (((unsigned int) u_category.level3[index3>>4]
| ((unsigned int) u_category.level3[(index3>>4)+1] << 16))
>> (index3 % 16))
& 0x1f;
unsigned int index3 = ((uc & joining_group_header_4) + lookup2) * 7;
/* level3 contains 7-bit values, packed into 16-bit words. */
unsigned int lookup3 =
- ((u_joining_group.level3[index3>>4]
+ (((unsigned int) u_joining_group.level3[index3>>4]
| ((unsigned int) u_joining_group.level3[(index3>>4)+1] << 16))
>> (index3 % 16))
& 0x7f;
unsigned int index3 = ((uc & numeric_header_4) + lookup2) * 8;
/* level3 contains 8-bit values, packed into 16-bit words. */
unsigned int lookup3 =
- ((u_numeric.level3[index3>>4]
- | (u_numeric.level3[(index3>>4)+1] << 16))
+ (((unsigned int) u_numeric.level3[index3>>4]
+ | ((unsigned int) u_numeric.level3[(index3>>4)+1] << 16))
>> (index3 % 16))
& 0xff;