From: Andre Date: Wed, 17 May 2006 15:39:31 +0000 (+0200) Subject: fix audiod command line option handling. X-Git-Tag: v0.2.14~110 X-Git-Url: http://git.tuebingen.mpg.de/?p=paraslash.git;a=commitdiff_plain;h=3bb167250b2b874c2c2cd9f8f5ef9abac9ed17e6 fix audiod command line option handling. The previous patch broke this. --- diff --git a/audiod.c b/audiod.c index 3d019311..8d1d8eb8 100644 --- 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) {