Skip to content

Commit

Permalink
fix(init): avoid TOCTTOU bug on syntax CSS dir
Browse files Browse the repository at this point in the history
  • Loading branch information
notriddle committed Sep 28, 2021
1 parent fbc4562 commit 1b24bd9
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions src/book/init.rs
Original file line number Diff line number Diff line change
Expand Up @@ -152,9 +152,7 @@ impl BookBuilder {
js.write_all(theme::JS)?;

let syntax_dir = cssdir.join("syntax");
if !syntax_dir.exists() {
fs::create_dir(&syntax_dir)?;
}
fs::create_dir_all(syntax_dir)?;

let mut highlight_css = File::create(syntax_dir.join("light.css"))?;
highlight_css.write_all(theme::SYNTAX_LIGHT_CSS)?;
Expand Down

0 comments on commit 1b24bd9

Please sign in to comment.