File tree Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Expand file tree Collapse file tree 1 file changed +20
-0
lines changed Original file line number Diff line number Diff line change @@ -1542,7 +1542,27 @@ impl Bindings {
1542
1542
}
1543
1543
}
1544
1544
1545
+ #[ cfg( unix) ]
1546
+ fn can_read ( perms : & std:: fs:: Permissions ) -> bool {
1547
+ use std:: os:: unix:: fs:: PermissionsExt ;
1548
+ perms. mode ( ) & 0o444 > 0
1549
+ }
1550
+
1551
+ #[ cfg( not( unix) ) ]
1552
+ fn can_read ( _: & std:: fs:: Permissions ) -> bool {
1553
+ true
1554
+ }
1555
+
1545
1556
if let Some ( h) = options. input_header . as_ref ( ) {
1557
+ let md = std:: fs:: metadata ( h) . ok ( ) . unwrap ( ) ;
1558
+ if !md. is_file ( ) {
1559
+ eprintln ! ( "error: '{}' is a folder" , h) ;
1560
+ return Err ( ( ) ) ;
1561
+ }
1562
+ if !can_read ( & md. permissions ( ) ) {
1563
+ eprintln ! ( "error: insufficient permissions to read '{}'" , h) ;
1564
+ return Err ( ( ) ) ;
1565
+ }
1546
1566
options. clang_args . push ( h. clone ( ) )
1547
1567
}
1548
1568
You can’t perform that action at this time.
0 commit comments