From f0f114ac9b184c90d9bd371ec99792d96b9a890c Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Tue, 29 May 2007 15:34:10 +0200 Subject: [PATCH] Be more paranoid about paths when updating the tree view Shell quote the path always. --- tig.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/tig.c b/tig.c index 7cf25ca..5e75b5a 100644 --- a/tig.c +++ b/tig.c @@ -269,6 +269,9 @@ sq_quote(char buf[SIZEOF_STR], size_t bufsize, const char *src) } BUFPUT('\''); + if (bufsize < SIZEOF_STR) + buf[bufsize] = 0; + return bufsize; } @@ -1786,11 +1789,14 @@ begin_update(struct view *view) } else if (view == VIEW(REQ_VIEW_TREE)) { const char *format = view->cmd_env ? view->cmd_env : view->cmd_fmt; + char path[SIZEOF_STR]; if (strcmp(view->vid, view->id)) - opt_path[0] = 0; + opt_path[0] = path[0] = 0; + else if (sq_quote(path, 0, opt_path) >= sizeof(path)) + return FALSE; - if (!string_format(view->cmd, format, id, opt_path)) + if (!string_format(view->cmd, format, id, path)) return FALSE; } else { -- 2.30.2