mirror of
https://github.com/opnsense/src.git
synced 2026-06-09 00:32:25 -04:00
libprocstat: simplify auxv value conversion
Avoid a weird dance through the union and treat all 32-bit values as unsigned integers. This avoids sign extension of flags and userspace pointers. Reviewed by: markj Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D42198
This commit is contained in:
parent
d62e01996e
commit
9735cc0e41
1 changed files with 11 additions and 3 deletions
|
|
@ -2414,7 +2414,6 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
|
|||
{
|
||||
Elf_Auxinfo *auxv;
|
||||
Elf32_Auxinfo *auxv32;
|
||||
void *ptr;
|
||||
size_t len;
|
||||
unsigned int i, count;
|
||||
int name[4];
|
||||
|
|
@ -2448,8 +2447,17 @@ procstat_getauxv32_sysctl(pid_t pid, unsigned int *cntp)
|
|||
* necessarily true.
|
||||
*/
|
||||
auxv[i].a_type = auxv32[i].a_type;
|
||||
ptr = &auxv32[i].a_un;
|
||||
auxv[i].a_un.a_val = *((uint32_t *)ptr);
|
||||
/*
|
||||
* Don't sign extend values. Existing entries are positive
|
||||
* integers or pointers. Under freebsd32, programs typically
|
||||
* have a full [0, 2^32) address space (perhaps minus the last
|
||||
* page) and treating this as a signed integer would be
|
||||
* confusing since these are not kernel pointers.
|
||||
*
|
||||
* XXX: A more complete translation would be ABI and
|
||||
* type-aware.
|
||||
*/
|
||||
auxv[i].a_un.a_val = (uint32_t)auxv32[i].a_un.a_val;
|
||||
}
|
||||
*cntp = count;
|
||||
out:
|
||||
|
|
|
|||
Loading…
Reference in a new issue