From bc899633e602bdd6d548d64689d61dcb7ac6ffad Mon Sep 17 00:00:00 2001 From: Pietro Cerutti Date: Tue, 24 Jan 2017 16:48:25 +0000 Subject: [PATCH] Avoid breaking relative paths when avoiding cyclic checks on pipes.. Pull: #290 --- init.c | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/init.c b/init.c index 9e2480630..70f955fb3 100644 --- a/init.c +++ b/init.c @@ -2666,29 +2666,35 @@ static int source_rc (const char *rcfile_path, BUFFER *err) char *currentline = NULL; char rcfile[PATH_MAX]; size_t buflen; + size_t rcfilelen; pid_t pid; strncpy(rcfile, rcfile_path, PATH_MAX); - if (!to_absolute_path(rcfile, mutt_front_heap(MuttrcHeap))) + rcfilelen = mutt_strlen(rcfile); + + if (rcfile[rcfilelen-1] != '|') { - mutt_error("Error: impossible to build path of '%s'.", rcfile_path); - return (-1); + if (!to_absolute_path(rcfile, mutt_front_heap(MuttrcHeap))) + { + mutt_error("Error: impossible to build path of '%s'.", rcfile_path); + return (-1); + } + + if (!MuttrcHeap || mutt_find_heap(MuttrcHeap, rcfile) == NULL) + { + mutt_push_heap(&MuttrcHeap, rcfile); + } + else + { + mutt_error("Error: Cyclic sourcing of configuration file '%s'.", rcfile); + return (-1); + } } dprint(2, (debugfile, "Reading configuration file '%s'.\n", rcfile)); - if (!MuttrcHeap || mutt_find_heap(MuttrcHeap, rcfile) == NULL) - { - mutt_push_heap(&MuttrcHeap, rcfile); - } - else - { - mutt_error("Error: Cyclic sourcing of configuration file '%s'.", rcfile); - return (-1); - } - if ((f = mutt_open_read (rcfile, &pid)) == NULL) { snprintf (err->data, err->dsize, "%s: %s", rcfile, strerror (errno)); -- 2.40.0