[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 2/5] util/getauxval: Ensure setting errno if not found
From: |
Richard Henderson |
Subject: |
[PULL 2/5] util/getauxval: Ensure setting errno if not found |
Date: |
Tue, 30 Jul 2024 11:11:59 +1000 |
From: Vivian Wang <uwu@dram.page>
Sometimes zero is a valid value for getauxval (e.g. AT_EXECFD). Make
sure that we can distinguish between a valid zero value and a not found
entry by setting errno.
Assumes that getauxval from sys/auxv.h sets errno correctly.
Signed-off-by: Vivian Wang <uwu@dram.page>
Message-ID: <20240723100545.405476-2-uwu@dram.page>
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
util/getauxval.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/util/getauxval.c b/util/getauxval.c
index b124107d61..ad4f6686a8 100644
--- a/util/getauxval.c
+++ b/util/getauxval.c
@@ -95,6 +95,7 @@ unsigned long qemu_getauxval(unsigned long type)
}
}
+ errno = ENOENT;
return 0;
}
@@ -104,7 +105,10 @@ unsigned long qemu_getauxval(unsigned long type)
unsigned long qemu_getauxval(unsigned long type)
{
unsigned long aux = 0;
- elf_aux_info(type, &aux, sizeof(aux));
+ int ret = elf_aux_info(type, &aux, sizeof(aux));
+ if (ret != 0) {
+ errno = ret;
+ }
return aux;
}
@@ -112,6 +116,7 @@ unsigned long qemu_getauxval(unsigned long type)
unsigned long qemu_getauxval(unsigned long type)
{
+ errno = ENOSYS;
return 0;
}
--
2.43.0
- [PULL 0/5] misc patch queue, Richard Henderson, 2024/07/29
- [PULL 2/5] util/getauxval: Ensure setting errno if not found,
Richard Henderson <=
- [PATCH for-9.1] tests/vm/openbsd: Install tomli, Richard Henderson, 2024/07/29
- [PULL 1/5] target/rx: Use target_ulong for address in LI, Richard Henderson, 2024/07/29
- [PULL 3/5] linux-user/main: Check errno when getting AT_EXECFD, Richard Henderson, 2024/07/29
- [PULL 4/5] util/cpuinfo: Make use of elf_aux_info(3) on OpenBSD, Richard Henderson, 2024/07/29
- [PULL 5/5] linux-user: open_self_stat: Implement num_threads, Richard Henderson, 2024/07/29
- Re: [PULL 0/5] misc patch queue, Richard Henderson, 2024/07/30