mirror of
https://github.com/asterisk/asterisk.git
synced 2025-10-25 06:00:36 +00:00
NULL character should terminate only commands back to the core, not log
messages to the console. (closes issue #12731) Reported by: seanbright Patches: 20080527__bug12731.diff.txt uploaded by Corydon76 (license 14) Tested by: seanbright git-svn-id: https://origsvn.digium.com/svn/asterisk/branches/1.4@118465 65c4cc65-6c06-0410-ace0-fbb531ad65f3
This commit is contained in:
@@ -738,11 +738,18 @@ void ast_unregister_atexit(void (*func)(void))
|
|||||||
free(ae);
|
free(ae);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int fdprint(int fd, const char *s)
|
/* Sending commands from consoles back to the daemon requires a terminating NULL */
|
||||||
|
static int fdsend(int fd, const char *s)
|
||||||
{
|
{
|
||||||
return write(fd, s, strlen(s) + 1);
|
return write(fd, s, strlen(s) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Sending messages from the daemon back to the display requires _excluding_ the terminating NULL */
|
||||||
|
static int fdprint(int fd, const char *s)
|
||||||
|
{
|
||||||
|
return write(fd, s, strlen(s));
|
||||||
|
}
|
||||||
|
|
||||||
/*! \brief NULL handler so we can collect the child exit status */
|
/*! \brief NULL handler so we can collect the child exit status */
|
||||||
static void null_sig_handler(int signal)
|
static void null_sig_handler(int signal)
|
||||||
{
|
{
|
||||||
@@ -1782,7 +1789,7 @@ static int ast_el_read_char(EditLine *el, char *cp)
|
|||||||
printf(term_quit());
|
printf(term_quit());
|
||||||
WELCOME_MESSAGE;
|
WELCOME_MESSAGE;
|
||||||
if (!ast_opt_mute)
|
if (!ast_opt_mute)
|
||||||
fdprint(ast_consock, "logger mute silent");
|
fdsend(ast_consock, "logger mute silent");
|
||||||
else
|
else
|
||||||
printf("log and verbose output currently muted ('logger mute' to unmute)\n");
|
printf("log and verbose output currently muted ('logger mute' to unmute)\n");
|
||||||
break;
|
break;
|
||||||
@@ -2094,7 +2101,7 @@ static char *cli_complete(EditLine *el, int ch)
|
|||||||
|
|
||||||
if (ast_opt_remote) {
|
if (ast_opt_remote) {
|
||||||
snprintf(buf, sizeof(buf),"_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr);
|
snprintf(buf, sizeof(buf),"_COMMAND NUMMATCHES \"%s\" \"%s\"", lf->buffer, ptr);
|
||||||
fdprint(ast_consock, buf);
|
fdsend(ast_consock, buf);
|
||||||
res = read(ast_consock, buf, sizeof(buf));
|
res = read(ast_consock, buf, sizeof(buf));
|
||||||
buf[res] = '\0';
|
buf[res] = '\0';
|
||||||
nummatches = atoi(buf);
|
nummatches = atoi(buf);
|
||||||
@@ -2106,7 +2113,7 @@ static char *cli_complete(EditLine *el, int ch)
|
|||||||
if (!(mbuf = ast_malloc(maxmbuf)))
|
if (!(mbuf = ast_malloc(maxmbuf)))
|
||||||
return (char *)(CC_ERROR);
|
return (char *)(CC_ERROR);
|
||||||
snprintf(buf, sizeof(buf),"_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr);
|
snprintf(buf, sizeof(buf),"_COMMAND MATCHESARRAY \"%s\" \"%s\"", lf->buffer, ptr);
|
||||||
fdprint(ast_consock, buf);
|
fdsend(ast_consock, buf);
|
||||||
res = 0;
|
res = 0;
|
||||||
mbuf[0] = '\0';
|
mbuf[0] = '\0';
|
||||||
while (!strstr(mbuf, AST_CLI_COMPLETE_EOF) && res != -1) {
|
while (!strstr(mbuf, AST_CLI_COMPLETE_EOF) && res != -1) {
|
||||||
@@ -2291,11 +2298,11 @@ static void ast_remotecontrol(char * data)
|
|||||||
pid = -1;
|
pid = -1;
|
||||||
if (!data) {
|
if (!data) {
|
||||||
snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
|
snprintf(tmp, sizeof(tmp), "core set verbose atleast %d", option_verbose);
|
||||||
fdprint(ast_consock, tmp);
|
fdsend(ast_consock, tmp);
|
||||||
snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
|
snprintf(tmp, sizeof(tmp), "core set debug atleast %d", option_debug);
|
||||||
fdprint(ast_consock, tmp);
|
fdsend(ast_consock, tmp);
|
||||||
if (!ast_opt_mute)
|
if (!ast_opt_mute)
|
||||||
fdprint(ast_consock, "logger mute silent");
|
fdsend(ast_consock, "logger mute silent");
|
||||||
else
|
else
|
||||||
printf("log and verbose output currently muted ('logger mute' to unmute)\n");
|
printf("log and verbose output currently muted ('logger mute' to unmute)\n");
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user