qrexec: use #define for protocol-specified strings
And optimize strlen() calls. Those defines are in qrexec.h (as the rest of qrexec protocol).
This commit is contained in:
parent
b6d4f5afbf
commit
823954c7f6
@ -84,7 +84,7 @@ void no_colon_in_cmd()
|
|||||||
*/
|
*/
|
||||||
void do_exec(const char *cmd)
|
void do_exec(const char *cmd)
|
||||||
{
|
{
|
||||||
char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - strlen(RPC_REQUEST_COMMAND) + 1];
|
char buf[strlen(QUBES_RPC_MULTIPLEXER_PATH) + strlen(cmd) - RPC_REQUEST_COMMAND_LEN + 1];
|
||||||
char *realcmd = index(cmd, ':');
|
char *realcmd = index(cmd, ':');
|
||||||
if (!realcmd)
|
if (!realcmd)
|
||||||
no_colon_in_cmd();
|
no_colon_in_cmd();
|
||||||
@ -92,12 +92,12 @@ void do_exec(const char *cmd)
|
|||||||
*realcmd = 0;
|
*realcmd = 0;
|
||||||
realcmd++;
|
realcmd++;
|
||||||
/* ignore "nogui:" prefix in linux agent */
|
/* ignore "nogui:" prefix in linux agent */
|
||||||
if (strncmp(realcmd, "nogui:", strlen("nogui:")) == 0)
|
if (strncmp(realcmd, NOGUI_CMD_PREFIX, NOGUI_CMD_PREFIX_LEN) == 0)
|
||||||
realcmd += strlen("nogui:");
|
realcmd += NOGUI_CMD_PREFIX_LEN;
|
||||||
/* replace magic RPC cmd with RPC multiplexer path */
|
/* replace magic RPC cmd with RPC multiplexer path */
|
||||||
if (strncmp(realcmd, RPC_REQUEST_COMMAND " ", strlen(RPC_REQUEST_COMMAND)+1)==0) {
|
if (strncmp(realcmd, RPC_REQUEST_COMMAND " ", RPC_REQUEST_COMMAND_LEN+1)==0) {
|
||||||
strcpy(buf, QUBES_RPC_MULTIPLEXER_PATH);
|
strcpy(buf, QUBES_RPC_MULTIPLEXER_PATH);
|
||||||
strcpy(buf + strlen(QUBES_RPC_MULTIPLEXER_PATH), realcmd + strlen(RPC_REQUEST_COMMAND));
|
strcpy(buf + strlen(QUBES_RPC_MULTIPLEXER_PATH), realcmd + RPC_REQUEST_COMMAND_LEN);
|
||||||
realcmd = buf;
|
realcmd = buf;
|
||||||
}
|
}
|
||||||
signal(SIGCHLD, SIG_DFL);
|
signal(SIGCHLD, SIG_DFL);
|
||||||
|
Loading…
Reference in New Issue
Block a user