1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/os
2022-11-06 08:22:28 +03:00
..
bare
cmdline
filelock os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
font os: fix font.v compilation 2022-10-27 11:13:43 +03:00
notify all: change optional to result of io (#16075) 2022-10-16 09:28:57 +03:00
args.v
const_nix.c.v
const_windows.c.v checker: check int overflow for const vars (#16332) 2022-11-06 08:22:28 +03:00
const.v
dir_expansions_test.v os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
environment_test.v
environment.c.v
environment.js.v
fd.c.v
file_test.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
file.c.v all: remove unnecessary IError() casts 2022-10-28 19:08:30 +03:00
file.js.v all: remove unnecessary IError() casts 2022-10-28 19:08:30 +03:00
filepath_test.v os: add os.to_slash and os.from_slash functions (#16055) 2022-10-14 10:22:36 +03:00
filepath_windows.v
filepath.v os: add os.to_slash and os.from_slash functions (#16055) 2022-10-14 10:22:36 +03:00
find_abs_path_of_executable_test.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
glob_test.v all: change optional to result of io (#16075) 2022-10-16 09:28:57 +03:00
inode_test.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
inode.c.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
open_uri_default.c.v all: change optional to result of io (#16075) 2022-10-16 09:28:57 +03:00
open_uri_windows.c.v all: change optional to result of io (#16075) 2022-10-16 09:28:57 +03:00
os_android_outside_termux.c.v checker: fix nested struct reference type field initialized check. (fix: #15741) (#15752) 2022-09-15 07:59:31 +03:00
os_darwin.c.v
os_js.js.v os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
os_linux.c.v
os_nix.c.v os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
os_structs_dirent_default.c.v
os_structs_sigaction_default.c.v
os_structs_stat_default.c.v
os_structs_stat_linux.c.v
os_structs_utsname_default.c.v
os_test.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
os_windows.c.v os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
os.c.v builtin: make the C. WIN32 API declarations more precise, to catch errors earlier (#16090) 2022-10-17 20:23:33 +03:00
os.js.v os: cleanup APIs returning !bool to either return ! or bool (#16111) 2022-10-20 13:56:06 +03:00
os.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
password_nix.c.v
password_windows.c.v
process_nix.c.v pref,os,sokol,cgen: ease compilation of 2048 with -os wasm32_emscripten (#15820) 2022-09-20 00:17:13 +03:00
process_test.v os,tools: add os.vtmp_dir() 2022-11-03 10:19:51 +02:00
process_windows.c.v checker: fix nested struct reference type field initialized check. (fix: #15741) (#15752) 2022-09-15 07:59:31 +03:00
process.c.v
process.js.v
process.v
README.md
signal_test.v
signal.c.v all: change optional to result of io (#16075) 2022-10-16 09:28:57 +03:00
signal.js.v
signal.v

Description:

os provides common OS/platform independent functions for accessing command line arguments, reading/writing files, listing folders, handling processes etc.


A few os module functions can lead to the TOCTOU vulnerability if used incorrectly. TOCTOU (Time-of-Check-to-Time-of-Use problem) can occur when a file, folder or similar is checked for certain specifications (e.g. read, write permissions) and a change is made afterwards. In the time between the initial check and the edit, an attacker can then cause damage. The following example shows an attack strategy on the left and an improved variant on the right so that TOCTOU is no longer possible.

Example Hint: os.create() opens a file in write-only mode

Possibility for TOCTOU attack
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') ?
        // <do something with file>
    f.close()
}
TOCTOU not possible
mut f := os.create('path/to/file') or {
    println("file not writable")
}

// >> do someting with file; file is locked <<

f.close()

Proven affected functions
The following functions should be used with care and only when used correctly.

  • os.is_readable()
  • os.is_writable()
  • os.is_executable()
  • os.is_link()