mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-05-30 09:20:07 +02:00
tools: Fix handling of empty argv in various minor GLib tools
This won’t really affect anything, but we might as well fix them to not crash if called with an empty `argv` by someone (ab)using `execve()`. Signed-off-by: Philip Withnall <pwithnall@endlessos.org>
This commit is contained in:
parent
0d743e7ffb
commit
3ea4ba31a1
@ -107,7 +107,7 @@ usage (gint *argc, gchar **argv[], gboolean use_stdout)
|
||||
g_option_context_set_help_enabled (o, FALSE);
|
||||
/* Ignore parsing result */
|
||||
g_option_context_parse (o, argc, argv, NULL);
|
||||
program_name = g_path_get_basename ((*argv)[0]);
|
||||
program_name = (*argc > 0) ? g_path_get_basename ((*argv)[0]) : g_strdup ("gdbus-tool");
|
||||
s = g_strdup_printf (_("Commands:\n"
|
||||
" help Shows this information\n"
|
||||
" introspect Introspect a remote object\n"
|
||||
@ -141,6 +141,7 @@ modify_argv0_for_command (gint *argc, gchar **argv[], const gchar *command)
|
||||
* 2. save old argv[0] and restore later
|
||||
*/
|
||||
|
||||
g_assert (*argc > 1);
|
||||
g_assert (g_strcmp0 ((*argv)[1], command) == 0);
|
||||
remove_arg (1, argc, argv);
|
||||
|
||||
|
@ -161,7 +161,7 @@ main (gint argc,
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc == 1)
|
||||
if (argc <= 1)
|
||||
{
|
||||
g_print ("Usage: gio-querymodules <directory1> [<directory2> ...]\n");
|
||||
g_print ("Will update giomodule.cache in the listed directories\n");
|
||||
|
@ -463,7 +463,8 @@ main (int argc,
|
||||
|
||||
if (argc < 3)
|
||||
{
|
||||
g_warning ("Usage: %s filename prefix1 [prefix2 ...]", argv[0]);
|
||||
g_warning ("Usage: %s filename prefix1 [prefix2 ...]",
|
||||
(argc > 0) ? argv[0] : "gcompletion");
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
@ -2034,7 +2034,8 @@ main(int argc, char **argv)
|
||||
|
||||
if (fromcode == NULL || tocode == NULL)
|
||||
{
|
||||
printf("usage: %s [-c] -f from-enc -t to-enc [file]\n", argv[0]);
|
||||
printf("usage: %s [-c] -f from-enc -t to-enc [file]\n",
|
||||
(argc > 0) ? argv[0] : "win_iconv");
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -196,7 +196,7 @@ main (gint argc,
|
||||
}
|
||||
|
||||
if (!gen_froots && !gen_tree)
|
||||
return help (argv[i-1]);
|
||||
return help ((argc > 0) ? argv[i-1] : NULL);
|
||||
|
||||
if (!indent_inc)
|
||||
{
|
||||
|
Loading…
x
Reference in New Issue
Block a user