Skip to content

Commit 61ba9fe

Browse files
authored
don't follow symlinks on file creation (#754)
1 parent 2732a12 commit 61ba9fe

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/image.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
use crate::io::snappy::SnapCountWriter;
55
use byteorder::{ByteOrder as _, LittleEndian, ReadBytesExt as _};
66
use core::ops::Range;
7+
#[cfg(target_family = "unix")]
8+
use libc::O_NOFOLLOW;
79
use snap::read::FrameDecoder;
810
#[cfg(target_family = "unix")]
911
use std::os::unix::fs::OpenOptionsExt as _;
@@ -191,6 +193,7 @@ impl<R: Read + Seek, W: Write> Image<R, W> {
191193
fn open_dst(path: &Path) -> Result<File> {
192194
OpenOptions::new()
193195
.mode(0o600)
196+
.custom_flags(O_NOFOLLOW)
194197
.write(true)
195198
.create(true)
196199
.truncate(true)

0 commit comments

Comments
 (0)