From 0450a933b93053fe464bfbcdee61b16b4e202149 Mon Sep 17 00:00:00 2001 From: Turiiya <34311583+ttytm@users.noreply.github.com> Date: Fri, 1 Sep 2023 15:09:04 +0200 Subject: [PATCH] os: update TOCTOU example in readme, to improve readability of the module docs on mobile (#19255) --- vlib/os/README.md | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/vlib/os/README.md b/vlib/os/README.md index 622a3446033453..c4537eca799c4f 100644 --- a/vlib/os/README.md +++ b/vlib/os/README.md @@ -23,28 +23,32 @@ so that TOCTOU is no longer possible. + + + + -
Possibility for TOCTOU attackTOCTOU not possible
-Possibility for TOCTOU attack - -```v ignore -if os.is_writable("file"){ - // >> time to make a quick attack (e.g. symlink /etc/passwd to >file<) << +```v ignore +if os.is_writable("file") { + // time to make a quick attack + // (e.g. symlink /etc/passwd to `file`) - mut f := os.create('path/to/file') ? - // + mut f := os.create('path/to/file')! + // do something with file f.close() } ``` TOCTOU not possible + ```v ignore mut f := os.create('path/to/file') or { println("file not writable") } -// >> do something with file; file is locked << +// file is locked +// do something with file f.close() ```