|
|
@ -1636,17 +1636,26 @@ static int action_command(struct mansession *s, const struct message *m)
|
|
|
|
/* FIXME: Wedge a ActionID response in here, waiting for later changes */
|
|
|
|
/* FIXME: Wedge a ActionID response in here, waiting for later changes */
|
|
|
|
ast_cli_command(fd, cmd); /* XXX need to change this to use a FILE * */
|
|
|
|
ast_cli_command(fd, cmd); /* XXX need to change this to use a FILE * */
|
|
|
|
l = lseek(fd, 0, SEEK_END); /* how many chars available */
|
|
|
|
l = lseek(fd, 0, SEEK_END); /* how many chars available */
|
|
|
|
buf = alloca(l + 1);
|
|
|
|
|
|
|
|
final_buf = alloca(l + 1);
|
|
|
|
/* This has a potential to overflow the stack. Hence, use the heap. */
|
|
|
|
|
|
|
|
buf = ast_calloc(1, l + 1);
|
|
|
|
|
|
|
|
final_buf = ast_calloc(1, l + 1);
|
|
|
|
|
|
|
|
if (buf) {
|
|
|
|
lseek(fd, 0, SEEK_SET);
|
|
|
|
lseek(fd, 0, SEEK_SET);
|
|
|
|
read(fd, buf, l);
|
|
|
|
read(fd, buf, l);
|
|
|
|
buf[l] = '\0';
|
|
|
|
buf[l] = '\0';
|
|
|
|
close(fd);
|
|
|
|
if (final_buf) {
|
|
|
|
unlink(template);
|
|
|
|
|
|
|
|
term_strip(final_buf, buf, l);
|
|
|
|
term_strip(final_buf, buf, l);
|
|
|
|
final_buf[l] = '\0';
|
|
|
|
final_buf[l] = '\0';
|
|
|
|
astman_append(s, final_buf);
|
|
|
|
}
|
|
|
|
|
|
|
|
astman_append(s, S_OR(final_buf, buf));
|
|
|
|
|
|
|
|
ast_free(buf);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
close(fd);
|
|
|
|
|
|
|
|
unlink(template);
|
|
|
|
astman_append(s, "--END COMMAND--\r\n\r\n");
|
|
|
|
astman_append(s, "--END COMMAND--\r\n\r\n");
|
|
|
|
|
|
|
|
if (final_buf)
|
|
|
|
|
|
|
|
ast_free(final_buf);
|
|
|
|
return 0;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|