wsutil: Warn on empty arguments

Callers should not include empty strings in arguments list. Log warning
message instead of silently dropping remaining arguments.

Change-Id: Ia68c7b90cec860e032f81a4008aa005b07ebcfd5
Ping-Bug: 15586
Reviewed-on: https://code.wireshark.org/review/32849
Petri-Dish: Anders Broman <a.broman58@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Anders Broman <a.broman58@gmail.com>
This commit is contained in:
Tomasz Moń 2019-04-14 11:39:27 +02:00 committed by Anders Broman
parent c464186bf9
commit 1998de886c
1 changed files with 8 additions and 2 deletions

View File

@ -524,7 +524,10 @@ GPid ws_pipe_spawn_async(ws_pipe_t *ws_pipe, GPtrArray *args)
/* convert args array into a single string */
/* XXX - could change sync_pipe_add_arg() instead */
/* there is a drawback here: the length is internally limited to 1024 bytes */
for (tmp = (gchar **)args->pdata, cnt = 0; *tmp && **tmp; ++cnt, ++tmp) {
for (tmp = (gchar **)args->pdata, cnt = 0; *tmp; ++cnt, ++tmp) {
if (!**tmp) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "Empty argument in arguments list");
}
if (cnt != 0) g_string_append_c(spawn_args, ' '); /* don't prepend a space before the path!!! */
quoted_arg = protect_arg(*tmp);
g_string_append(spawn_args, quoted_arg);
@ -557,7 +560,10 @@ GPid ws_pipe_spawn_async(ws_pipe_t *ws_pipe, GPtrArray *args)
/* convert args array into a single string */
/* XXX - could change sync_pipe_add_arg() instead */
/* there is a drawback here: the length is internally limited to 1024 bytes */
for (tmp = (gchar **)args->pdata, cnt = 0; *tmp && **tmp; ++cnt, ++tmp) {
for (tmp = (gchar **)args->pdata, cnt = 0; *tmp; ++cnt, ++tmp) {
if (!**tmp) {
g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "Empty argument in arguments list");
}
if (cnt != 0) g_string_append_c(spawn_args, ' '); /* don't prepend a space before the path!!! */
quoted_arg = g_shell_quote(*tmp);
g_string_append(spawn_args, quoted_arg);