Check elf_aux_info() return value in hasFastAes()

Check the result of elf_aux_info() on FreeBSD and OpenBSD ARM and fall
back to no AES support if the call fails, rather than relying on the
output variable being left untouched.
This commit is contained in:
Brad Smith
2026-10-02 23:10:50 -05:00
committed by Cameron Gutman
parent 8369d1a0e1
commit a2486eaf94
+6 -4
View File
@@ -222,12 +222,14 @@ bool StreamUtils::hasFastAes()
// Everything that runs Catalina and later has AES-NI or ARMv8 crypto instructions
return true;
#elif (defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)) && defined(Q_PROCESSOR_ARM) && QT_POINTER_SIZE == 4
unsigned long hwcap2 = 0;
elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
unsigned long hwcap2;
if (elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2)) != 0)
hwcap2 = 0;
return (hwcap2 & HWCAP2_AES);
#elif (defined(Q_OS_FREEBSD) || defined(Q_OS_OPENBSD)) && defined(Q_PROCESSOR_ARM) && QT_POINTER_SIZE == 8
unsigned long hwcap = 0;
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
unsigned long hwcap;
if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) != 0)
hwcap = 0;
return (hwcap & HWCAP_AES);
#elif defined(Q_OS_LINUX) && defined(Q_PROCESSOR_ARM) && QT_POINTER_SIZE == 4
return getauxval(AT_HWCAP2) & HWCAP2_AES;