Skip to content

Commit

Permalink
Fix: remove additional argv when previously set on proctitle_set
Browse files Browse the repository at this point in the history
To prevent proctitle to include all additional argv parameter to the
title it sets argv[1] to NULL when argc is larger than 1.
  • Loading branch information
nichtsfrei committed Apr 28, 2022
1 parent 5f6f65a commit 8a18171
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion base/proctitle.c
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ extern const char *__progname;
extern const char *__progname_full;
#endif
static char **old_argv;
static int old_argc;
extern char **environ;
void *current_environ = NULL;

Expand All @@ -62,7 +63,7 @@ proctitle_init (int argc, char **argv)
#else
char *new_progname;
#endif
(void) argc;
old_argc = argc;

if (argv == NULL)
return;
Expand Down Expand Up @@ -115,6 +116,9 @@ proctitle_set_args (const char *new_title, va_list args)
// we omit one to be 0 terminated
memcpy (old_argv[0], formatted, 255);
g_free (formatted);
// omit previous additional parameter
if (old_argc > 1)
old_argv[1] = NULL;
}

/**
Expand Down

0 comments on commit 8a18171

Please sign in to comment.