diff options
author | Vivian Wang <uwu@dram.page> | 2024-07-23 18:05:44 +0800 |
---|---|---|
committer | Richard Henderson <richard.henderson@linaro.org> | 2024-07-30 07:59:23 +1000 |
commit | 22531d8cc58f390986e7070eca5d1628aa7b2fe0 (patch) | |
tree | 9c47752add83f4b73e98ee47666b30c68f567444 /util/getauxval.c | |
parent | 83340193b991e7a974f117baa86a04db1fd835a9 (diff) |
util/getauxval: Ensure setting errno if not found
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>
Diffstat (limited to 'util/getauxval.c')
-rw-r--r-- | util/getauxval.c | 7 |
1 files changed, 6 insertions, 1 deletions
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; } |