1
0
mirror of https://github.com/weechat/weechat.git synced 2026-07-10 00:45:41 +02:00

core: do not call shell to execute command in hook_process (fix security problem when a plugin/script gives untrusted command) (bug #37764)

This commit is contained in:
Sebastien Helleu
2012-11-18 10:38:30 +01:00
parent c1389f8fe1
commit efb795c74f
4 changed files with 212 additions and 5 deletions
+3 -1
View File
@@ -1,12 +1,14 @@
WeeChat ChangeLog
=================
Sébastien Helleu <flashcode@flashtux.org>
v0.4.0-dev, 2012-11-14
v0.4.0-dev, 2012-11-18
Version 0.4.0 (under dev!)
--------------------------
* core: do not call shell to execute command in hook_process (fix security
problem when a plugin/script gives untrusted command) (bug #37764)
* core: stop cmake if gcrypt lib is not found (bug #37671)
* core: add incomplete mouse events "event-down" and "event-drag" (task #11840)
* core: add command /eval, use expression in conditions for bars
+18 -4
View File
@@ -1388,9 +1388,9 @@ hook_process (struct t_weechat_plugin *plugin,
void
hook_process_child (struct t_hook *hook_process)
{
char *exec_args[4] = { "sh", "-c", NULL, NULL };
char **exec_args;
const char *ptr_url;
int rc;
int rc, i;
/*
* close stdin, so that process will fail to read stdin (process reading
@@ -1429,10 +1429,24 @@ hook_process_child (struct t_hook *hook_process)
else
{
/* launch command */
exec_args[2] = HOOK_PROCESS(hook_process, command);
execvp (exec_args[0], exec_args);
exec_args = string_split_shell (HOOK_PROCESS(hook_process, command));
if (exec_args)
{
if (weechat_debug_core >= 1)
{
log_printf ("hook_process, command='%s'",
HOOK_PROCESS(hook_process, command));
for (i = 0; exec_args[i]; i++)
{
log_printf (" args[%02d] == '%s'", i, exec_args[i]);
}
}
execvp (exec_args[0], exec_args);
}
/* should not be executed if execvp was ok */
if (exec_args)
string_free_split (exec_args);
fprintf (stderr, "Error with command '%s'\n",
HOOK_PROCESS(hook_process, command));
rc = EXIT_FAILURE;
File diff suppressed because it is too large Load Diff
+1
View File
@@ -59,6 +59,7 @@ extern int string_has_highlight_regex_compiled (const char *string,
extern int string_has_highlight_regex (const char *string, const char *regex);
extern char **string_split (const char *string, const char *separators,
int keep_eol, int num_items_max, int *num_items);
extern char **string_split_shell (const char *string);
extern void string_free_split (char **split_string);
extern char *string_build_with_split_string (const char **split_string,
const char *separator);