These commands use prepare_command() to find a channel to act on, which returns the server to use.
The code should then use my_send_to_server() to ensure that it sends the command to that server -
these functions were using send_to_server() which sends to 'from_server', which means that they
could send the commands to the wrong place, for example if they were called from a hook on a
different server.
This patch was created with the following coccinelle script:
// Detects pairing preprare_command() with send_to_server() (which uses from_server)
@prepare3@
identifier s;
local idexpression c;
expression E1, E2, E3, E4, E5;
@@
(
if ((c = prepare_command(&s,...)) != NULL && ...)
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
|
if ((c = prepare_command(&s,...)) == NULL || ...) { ... return ...; }
{
<...
(
- send_to_server(E1);
+ my_send_to_server(s, E1);
|
- send_to_server(E1,E2);
+ my_send_to_server(s, E1, E2);
|
- send_to_server(E1,E2,E3);
+ my_send_to_server(s, E1, E2, E3);
|
- send_to_server(E1,E2,E3,E4);
+ my_send_to_server(s, E1, E2, E3, E4);
|
- send_to_server(E1,E2,E3,E4,E5);
+ my_send_to_server(s, E1, E2, E3, E4, E5);
)
...>
}
)