Both para_client and para_audioc create an argument vector from the
given command line using create_argv(). If the command line contains
only whitespace characters, this vector has length zero, and argv[0]
is NULL.
We missed to check for this at at least three places in audioc.c,
client.c and audiod_command.c, which resulted in crashes due to NULL
pointer dereferences or failed assertions.
These bugs can easily be triggered by starting para_client or
para_audioc in interactive mode, entering a single space character
and hitting return.
This patch adds the missing checks to prevent the crashes.
conf.inputs_num = ret;
args = concat_args(conf.inputs_num, conf.inputs);
free_argv(conf.inputs);
+ if (!args)
+ return 0;
conf.inputs_num = 0; /* required for audioc_cmdline_parser_free() */
ret = connect_audiod(socket_name, args);
if (ret < 0)
if (ret < 0)
goto out;
ret = create_argv(buf, "\n", &argv);
- if (ret < 0)
+ if (ret <= 0)
goto out;
argc = ret;
//PARA_INFO_LOG("argv[0]: %s, argc = %d\n", argv[0], argc);
client_disconnect(ct);
PARA_DEBUG_LOG("line: %s\n", line);
ret = make_client_argv(line);
- if (ret < 0)
+ if (ret <= 0)
return ret;
ret = client_connect(ct, &sched, NULL, NULL);
if (ret < 0)