From: Jonas Fonseca Date: Tue, 29 May 2007 13:34:10 +0000 (+0200) Subject: Be more paranoid about paths when updating the tree view X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=f0f114ac9b184c90d9bd371ec99792d96b9a890c;p=tig.git Be more paranoid about paths when updating the tree view Shell quote the path always. --- 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 {