fix audiod command line option handling.
authorAndre <maan@p133.(none)>
Wed, 17 May 2006 15:39:31 +0000 (17:39 +0200)
committerAndre <maan@p133.(none)>
Wed, 17 May 2006 15:39:31 +0000 (17:39 +0200)
The previous patch broke this.

audiod.c

index 3d01931..8d1d8eb 100644 (file)
--- a/audiod.c
+++ b/audiod.c
@@ -1431,7 +1431,7 @@ static int check_perms(uid_t uid)
 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));
@@ -1446,7 +1446,8 @@ static int handle_connect(void)
        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 {
@@ -1455,7 +1456,7 @@ static int handle_connect(void)
        }
        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");
@@ -1466,12 +1467,13 @@ static int handle_connect(void)
                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) {