static int handle_connect(void)
{
int i, argc, ret, clifd = -1;
- char *p, *buf = para_malloc(MAXLINE), **argv = NULL;
+ char *cmd = NULL, *p, *buf = para_calloc(MAXLINE), **argv = NULL;
struct sockaddr_un unix_addr;
ret = para_accept(audiod_socket, &unix_addr, sizeof(struct sockaddr_un));
if (ret < 0)
goto out;
ret = -E_INVALID_AUDIOD_CMD;
- p = strchr(buf, '\n');
+ cmd = para_strdup(buf);
+ p = strchr(cmd, '\n');
if (!p)
p = "";
else {
}
for (i = 0; cmds[i].name; i++) {
int j;
- if (strcmp(cmds[i].name, buf))
+ if (strcmp(cmds[i].name, cmd))
continue;
if (cmds[i].handler) {
argc = split_args(buf, &argv, "\n");
for (j = 0; p[j]; j++)
if (p[j] == '\n')
p[j] = ' ';
- PARA_INFO_LOG("cmd: %s, options: %s\n", buf, p);
+ PARA_INFO_LOG("cmd: %s, options: %s\n", cmd, p);
ret = cmds[i].line_handler(clifd, p);
goto out;
}
ret = -E_INVALID_AUDIOD_CMD; /* cmd not found */
out:
+ free(cmd);
free(buf);
free(argv);
if (clifd > 0 && ret < 0 && ret != -E_CLIENT_WRITE) {