mirror of git://sourceware.org/git/glibc.git
x86: Fix UB in x86_cpu_present/x86_cpu_active
The elf/tst-cpu-features-supports (and other tests that check for CPU features) triggers the following issue with ubsan: UBSAN: Undefined behaviour in ../sysdeps/x86/sys/platform/x86.h:59:42 left shift of 1 by 31 cannot be represented in type 'int' The active_array is unsigned, so use an unsigned constant as well.
This commit is contained in:
parent
8cc687cbac
commit
7417fcf25a
|
|
@ -40,7 +40,7 @@ x86_cpu_present (unsigned int __index)
|
|||
unsigned int __bit = __reg & (8 * sizeof (unsigned int) - 1);
|
||||
__reg /= 8 * sizeof (unsigned int);
|
||||
|
||||
return __ptr->cpuid_array[__reg] & (1 << __bit);
|
||||
return __ptr->cpuid_array[__reg] & (1U << __bit);
|
||||
}
|
||||
|
||||
static __inline__ bool
|
||||
|
|
@ -56,7 +56,7 @@ x86_cpu_active (unsigned int __index)
|
|||
unsigned int __bit = __reg & (8 * sizeof (unsigned int) - 1);
|
||||
__reg /= 8 * sizeof (unsigned int);
|
||||
|
||||
return __ptr->active_array[__reg] & (1 << __bit);
|
||||
return __ptr->active_array[__reg] & (1U << __bit);
|
||||
}
|
||||
|
||||
/* CPU_FEATURE_PRESENT evaluates to true if CPU supports the feature. */
|
||||
|
|
|
|||
Loading…
Reference in New Issue