File tree 1 file changed +10
-1
lines changed
1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -49,6 +49,15 @@ fn ensure_no_nuls<T: AsRef<OsStr>>(str: T) -> io::Result<T> {
49
49
}
50
50
}
51
51
52
+ fn ensure_valid_env_key < T : AsRef < OsStr > > ( str : T ) -> io:: Result < T > {
53
+ if str. as_ref ( ) . is_empty ( ) || str. as_ref ( ) . encode_wide ( ) . skip ( 1 ) . any ( |b| b == b'=' as u16 ) {
54
+ Err ( io:: Error :: new ( io:: ErrorKind :: InvalidInput ,
55
+ "malformed env key in provided data" ) )
56
+ } else {
57
+ ensure_no_nuls ( str)
58
+ }
59
+ }
60
+
52
61
pub struct Command {
53
62
program : OsString ,
54
63
args : Vec < OsString > ,
@@ -479,7 +488,7 @@ fn make_envp(env: Option<&collections::HashMap<OsString, OsString>>)
479
488
let mut blk = Vec :: new ( ) ;
480
489
481
490
for pair in env {
482
- blk. extend ( ensure_no_nuls ( pair. 0 ) ?. encode_wide ( ) ) ;
491
+ blk. extend ( ensure_valid_env_key ( pair. 0 ) ?. encode_wide ( ) ) ;
483
492
blk. push ( '=' as u16 ) ;
484
493
blk. extend ( ensure_no_nuls ( pair. 1 ) ?. encode_wide ( ) ) ;
485
494
blk. push ( 0 ) ;
You can’t perform that action at this time.
0 commit comments