elf_aux_info() returns an errno value (0 on success) rather than -1
with errno set. Ignoring the return value means the result is
unreliable on failure. Treat a failure as "no features reported" so
the generic code is used.
Signed-off-by: Brad Smith <brad(a)comstyle.com>
---
fat-arm64.c | 3 ++-
fat-ppc.c | 6 ++++--
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/fat-arm64.c b/fat-arm64.c
index 36136078..e5b8a93b 100644
--- a/fat-arm64.c
+++ b/fat-arm64.c
@@ -141,7 +141,8 @@ get_arm64_features (struct arm64_features *features)
#if USE_GETAUXVAL
hwcap = getauxval(AT_HWCAP);
#elif defined(HAVE_ELF_AUX_INFO)
- elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
+ if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) != 0)
+ hwcap = 0;
#endif
features->have_aes
diff --git a/fat-ppc.c b/fat-ppc.c
index 39ba6a3d..52514e0a 100644
--- a/fat-ppc.c
+++ b/fat-ppc.c
@@ -130,8 +130,10 @@ get_ppc_features (struct ppc_features *features)
hwcap = getauxval(AT_HWCAP);
hwcap2 = getauxval(AT_HWCAP2);
# elif defined(HAVE_ELF_AUX_INFO)
- elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
- elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));
+ if (elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap)) != 0)
+ hwcap = 0;
+ if (elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2)) != 0)
+ hwcap2 = 0;
# elif defined(__FreeBSD__)
size_t len;
len = sizeof(hwcap);
--
2.55.0