@@ -189,13 +189,12 @@ fn getauxval(key: usize) -> Result<usize, ()> {
189
189
pub ( super ) fn auxv_from_file ( file : & str ) -> Result < AuxVec , ( ) > {
190
190
let file = super :: read_file ( file) ?;
191
191
192
- // See <https://github.com/torvalds/linux/blob/v3.19 /include/uapi/linux/auxvec.h>.
192
+ // See <https://github.com/torvalds/linux/blob/v5.15 /include/uapi/linux/auxvec.h>.
193
193
//
194
- // The auxiliary vector contains at most 32 (key,value) fields: from
195
- // `AT_EXECFN = 31` to `AT_NULL = 0`. That is, a buffer of
196
- // 2*32 `usize` elements is enough to read the whole vector.
197
- let mut buf = [ 0_usize ; 64 ] ;
198
- let len = core:: mem:: size_of_val ( & buf) . max ( file. len ( ) ) ;
194
+ // The auxiliary vector contains at most 34 (key,value) fields: from
195
+ // `AT_MINSIGSTKSZ` to `AT_NULL`, but its number may increase.
196
+ let len = file. len ( ) ;
197
+ let mut buf = alloc:: vec![ 0_usize ; 1 + len / core:: mem:: size_of:: <usize >( ) ] ;
199
198
unsafe {
200
199
core:: ptr:: copy_nonoverlapping ( file. as_ptr ( ) , buf. as_mut_ptr ( ) as * mut u8 , len) ;
201
200
}
@@ -206,7 +205,7 @@ pub(super) fn auxv_from_file(file: &str) -> Result<AuxVec, ()> {
206
205
/// Tries to interpret the `buffer` as an auxiliary vector. If that fails, this
207
206
/// function returns `Err`.
208
207
#[ cfg( feature = "std_detect_file_io" ) ]
209
- fn auxv_from_buf ( buf : & [ usize ; 64 ] ) -> Result < AuxVec , ( ) > {
208
+ fn auxv_from_buf ( buf : & [ usize ] ) -> Result < AuxVec , ( ) > {
210
209
// Targets with only AT_HWCAP:
211
210
#[ cfg( any(
212
211
target_arch = "riscv32" ,
0 commit comments