Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

PATCH: PATCH: More sanity checks for vcs_info



Before, this could screw you:
cd /tmp; mkdir test; cd test; sudo chown root .; sudo chmod 700 .
---
 Functions/VCS_Info/VCS_INFO_bydir_detect |    1 +
 Functions/VCS_Info/vcs_info              |    2 ++
 2 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/Functions/VCS_Info/VCS_INFO_bydir_detect b/Functions/VCS_Info/VCS_INFO_bydir_detect
index 7985b69..0b5996f 100644
--- a/Functions/VCS_Info/VCS_INFO_bydir_detect
+++ b/Functions/VCS_Info/VCS_INFO_bydir_detect
@@ -8,6 +8,7 @@ local basedir="." realbasedir
 
 realbasedir="$(VCS_INFO_realpath ${basedir})"
 while [[ ${realbasedir} != '/' ]]; do
+    [[ -r ${realbasedir} ]] || return 1
     if [[ -n ${vcs_comm[detect_need_file]} ]] ; then
         [[ -d ${basedir}/${dirname} ]] && \
         [[ -e ${basedir}/${dirname}/${vcs_comm[detect_need_file]} ]] && \
diff --git a/Functions/VCS_Info/vcs_info b/Functions/VCS_Info/vcs_info
index a821e4d..4344d0b 100644
--- a/Functions/VCS_Info/vcs_info
+++ b/Functions/VCS_Info/vcs_info
@@ -41,6 +41,8 @@ vcs_info () {
     emulate -L zsh
     setopt extendedglob
 
+    [[ -r . ]] || return 0
+
     local pat
     local -i found
     local -a enabled disabled dps
-- 
1.6.5.rc2



Messages sorted by: Reverse Date, Date, Thread, Author