Skip to content

Commit 1eed458

Browse files
committed
chore: snapshot protect against write dest being a dir
1 parent 266b31c commit 1eed458

File tree

1 file changed

+6
-0
lines changed
  • soroban-ledger-snapshot/src

1 file changed

+6
-0
lines changed

soroban-ledger-snapshot/src/lib.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ impl LedgerSnapshot {
231231
/// If a file already exists at path `p`, it will be replaced.
232232
pub fn write_file(&self, p: impl AsRef<Path>) -> Result<(), Error> {
233233
let p = p.as_ref();
234+
if p.is_dir() {
235+
return Err(Error::Io(std::io::Error::new(
236+
std::io::ErrorKind::IsADirectory,
237+
"destination path is a directory",
238+
)));
239+
}
234240
if let Some(dir) = p.parent() {
235241
if !dir.exists() {
236242
create_dir_all(dir)?;

0 commit comments

Comments
 (0)