From 4660efdd48948d003cbcc35f2a15401cf4c5f8ea Mon Sep 17 00:00:00 2001 From: imlk Date: Mon, 26 Jul 2021 08:30:50 +0800 Subject: [PATCH] fix: add check for .push("") in translate_path_at() --- src/process/tracee.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/process/tracee.rs b/src/process/tracee.rs index fa72c40..145d09f 100644 --- a/src/process/tracee.rs +++ b/src/process/tracee.rs @@ -6,6 +6,7 @@ use std::rc::Rc; use nix::sys::ptrace::{self, Options}; use nix::sys::signal::Signal; use nix::unistd::Pid; +use nix::NixPath; use crate::errors::*; use crate::filesystem::Substitutor; @@ -259,7 +260,10 @@ impl Tracee { ) -> Result { if guest_path.as_ref().is_relative() { let mut dir_path = self.get_path_from_fd(dirfd, Side::Guest)?; - dir_path.push(guest_path); + // Check if guest_path is empty to avoid side effects of .push() + if !guest_path.as_ref().is_empty() { + dir_path.push(guest_path); + } self.fs .borrow() .translate_absolute_path(dir_path, deref_final)