aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author_ov4 <ov4@ov4.org>2026-10-09 12:40:27 +0000
committer_ov4 <ov4@ov4.org>2026-10-09 12:40:27 +0000
commit17e0735f00cb0f5effda63844a3b0d4b58eae0a7 (patch)
tree312e9b48b4ea45e042c71bf99c8abe322ec87c93
parent0d8588c8e206030d96dce2f59e155e8f699f39f6 (diff)
fix open() follow link vulnerability (O_NOFOLLOW)
-rw-r--r--src/history.cc2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/history.cc b/src/history.cc
index 5ba33ea..5394835 100644
--- a/src/history.cc
+++ b/src/history.cc
@@ -70,7 +70,7 @@ void save_history(const string &path)
* So we just write to a temp file, and rename it to replace the "real" history file
*/
string tmp_path = path + ".tmp";
- int fd = open(tmp_path.c_str(), (O_WRONLY | O_CREAT | O_TRUNC), (S_IRUSR | S_IWUSR));
+ int fd = open(tmp_path.c_str(), (O_WRONLY | O_CREAT | O_TRUNC | O_NOFOLLOW), (S_IRUSR | S_IWUSR));
if (fd == -1)
{
loggerln("save_history: fail to open() history");