1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00
v/vlib/os
2023-08-09 15:04:44 +03:00
..
bare
cmdline
filelock
font all: 2023 copyright 2023-03-28 22:55:57 +02:00
notify os.notify: remove the meaningless [noinit] attribute of the notifier (#19075) 2023-08-07 09:19:54 +03:00
args.v all: 2023 copyright 2023-03-28 22:55:57 +02:00
const_nix.c.v
const_windows.c.v
const.v
debugger_darwin.c.v os: add #include <sys/types.h> to debugger_darwin.c.v, to fix bootstrapping on macOS <= 11 (#17446) 2023-03-01 00:06:12 +02:00
debugger_default.c.v os: move pub fn debugger_present() bool{ to platform-specific files (better ptrace portability handling) (#17373) 2023-02-21 10:55:03 +02:00
debugger_freebsd.c.v ci: fix bootstrapping on macos/freebsd etc 2023-02-21 12:30:35 +02:00
debugger_linux.c.v ci: fix bootstrapping on macos/freebsd etc 2023-02-21 12:30:35 +02:00
debugger_windows.c.v ci: fix bootstrapping on macos/freebsd etc 2023-02-21 12:30:35 +02:00
dir_expansions_test.v
environment_test.v
environment.c.v all: 2023 copyright 2023-03-28 22:55:57 +02:00
environment.js.v
fd.c.v
file_test.v os: fix truncate() on windows (#18262) 2023-05-25 14:37:53 +03:00
file.c.v os: fix truncate() on windows (#18262) 2023-05-25 14:37:53 +03:00
file.js.v
filepath_test.v
filepath_windows.v
filepath.v checker: check option fn returning error (fix #17423) (#17438) 2023-03-02 15:49:50 +02:00
find_abs_path_of_executable_test.v
glob_test.v
inode_test.v
inode.c.v all: 2023 copyright 2023-03-28 22:55:57 +02:00
open_uri_default.c.v
open_uri_windows.c.v
os_android_outside_termux.c.v
os_darwin.c.v all: 2023 copyright 2023-03-28 22:55:57 +02:00
os_js.js.v os: return the long path for os.temp_dir() on windows, even for folders like c:\someth~1 (#17623) 2023-03-14 00:51:52 +02:00
os_linux.c.v all: 2023 copyright 2023-03-28 22:55:57 +02:00
os_nix.c.v checker: disallow struct int to ptr outside unsafe (#17923) 2023-04-13 07:38:21 +02: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: make hostname and loginname functions return Result (#17414) 2023-02-27 05:21:23 +03:00
os_windows.c.v builtin,os: fix compiling V programs with latest clang 16 on windows (clang 16 is stricter than clang 14) (#19095) 2023-08-09 15:04:44 +03:00
os.c.v parser: remove hardcoded check for function calls for C.stat, C.sigaction, etc (#18535) 2023-06-24 08:03:12 +03:00
os.js.v
os.v all: 2023 copyright 2023-03-28 22:55:57 +02:00
password_nix.c.v os,term.termios: add termios.set_state/2, state.disable_echo/0, use them in os.input_password, to fix v -os wasm32_emscripten examples/2048/ 2023-07-31 10:28:45 +03:00
password_windows.c.v
process_nix.c.v os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946) 2023-04-13 14:48:32 +03:00
process_test.v os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946) 2023-04-13 14:48:32 +03:00
process_windows.c.v os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946) 2023-04-13 14:48:32 +03:00
process.c.v
process.js.v
process.v os: implement Process.set_work_folder/0 to set the initial working folder of the new child process (#17946) 2023-04-13 14:48:32 +03:00
README.md docs: fix typos using codespell (#17332) 2023-02-16 11:43:39 +02:00
signal_test.v
signal.c.v
signal.js.v os: return the long path for os.temp_dir() on windows, even for folders like c:\someth~1 (#17623) 2023-03-14 00:51:52 +02:00
signal.v os: make SignalHandler public (#18115) 2023-05-06 14:59:06 +03:00

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 something 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()