File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change @@ -167,12 +167,19 @@ impl Tzif {
167
167
168
168
#[ cfg( target_family = "unix" ) ]
169
169
pub fn read_tzif ( identifier : & str ) -> TemporalResult < Self > {
170
+ // Protect from path traversal attacks
171
+ if identifier. starts_with ( '/' ) || identifier. contains ( '.' ) {
172
+ return Err ( TemporalError :: range ( ) . with_message ( "Ill-formed timezone identifier" ) ) ;
173
+ }
170
174
let mut path = PathBuf :: from ( ZONEINFO_DIR ) ;
171
175
path. push ( identifier) ;
172
176
Self :: from_path ( & path)
173
177
}
174
178
175
179
pub fn from_path ( path : & Path ) -> TemporalResult < Self > {
180
+ if !path. exists ( ) {
181
+ return Err ( TemporalError :: range ( ) . with_message ( "Unknown timezone identifier" ) ) ;
182
+ }
176
183
tzif:: parse_tzif_file ( path)
177
184
. map ( Into :: into)
178
185
. map_err ( |e| TemporalError :: general ( e. to_string ( ) ) )
You can’t perform that action at this time.
0 commit comments