@@ -71,13 +71,13 @@ impl<'tcx> UnixEnvVars<'tcx> {
71
71
self . environ . ptr ( )
72
72
}
73
73
74
- /// Implementation detail for [`InterpCx::get_var `]. This basically does `getenv`, complete
74
+ /// Implementation detail for [`InterpCx::get_env_var `]. This basically does `getenv`, complete
75
75
/// with the reads of the environment, but returns an [`OsString`] instead of a pointer.
76
76
pub ( crate ) fn get < ' mir > (
77
77
& self ,
78
78
ecx : & InterpCx < ' mir , ' tcx , MiriMachine < ' mir , ' tcx > > ,
79
79
name : & OsStr ,
80
- ) -> InterpResult < ' tcx , Option < OsString > > {
80
+ ) -> InterpResult < ' tcx , Option < Pointer < Option < Provenance > > > > {
81
81
// We don't care about the value as we have the `map` to keep track of everything,
82
82
// but we do want to do this read so it shows up as a data race.
83
83
let _vars_ptr = ecx. read_pointer ( & self . environ ) ?;
@@ -89,7 +89,7 @@ impl<'tcx> UnixEnvVars<'tcx> {
89
89
Size :: from_bytes ( u64:: try_from ( name. len ( ) ) . unwrap ( ) . checked_add ( 1 ) . unwrap ( ) ) ,
90
90
ecx,
91
91
) ?;
92
- ecx . read_os_str_from_c_str ( var_ptr ) . map ( |s| Some ( s . to_owned ( ) ) )
92
+ Ok ( Some ( var_ptr ) )
93
93
}
94
94
}
95
95
@@ -137,19 +137,8 @@ pub trait EvalContextExt<'mir, 'tcx: 'mir>: crate::MiriInterpCxExt<'mir, 'tcx> {
137
137
let name_ptr = this. read_pointer ( name_op) ?;
138
138
let name = this. read_os_str_from_c_str ( name_ptr) ?;
139
139
140
- // We don't care about the value as we have the `map` to keep track of everything,
141
- // but we do want to do this read so it shows up as a data race.
142
- let _vars_ptr = this. read_pointer ( & this. machine . env_vars . unix ( ) . environ ) ?;
143
- Ok ( match this. machine . env_vars . unix ( ) . map . get ( name) {
144
- Some ( var_ptr) => {
145
- // The offset is used to strip the "{name}=" part of the string.
146
- var_ptr. offset (
147
- Size :: from_bytes ( u64:: try_from ( name. len ( ) ) . unwrap ( ) . checked_add ( 1 ) . unwrap ( ) ) ,
148
- this,
149
- ) ?
150
- }
151
- None => Pointer :: null ( ) ,
152
- } )
140
+ let var_ptr = this. machine . env_vars . unix ( ) . get ( this, name) ?;
141
+ Ok ( var_ptr. unwrap_or_else ( Pointer :: null) )
153
142
}
154
143
155
144
fn setenv (
0 commit comments