From: Thomas Weißschuh Date: Sun, 24 Dec 2023 11:00:53 +0000 (+0100) Subject: exec_shell: use xasprintf X-Git-Tag: v2.40-rc1~84^2~18 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=b377f9ab15c87933281f6821819d7e43ac0d3b49;p=thirdparty%2Futil-linux.git exec_shell: use xasprintf It removes an unbounded strcpy and makes the code shorter and clearer. Signed-off-by: Thomas Weißschuh --- diff --git a/lib/exec_shell.c b/lib/exec_shell.c index 6fef6c7a32..96d3e95a8d 100644 --- a/lib/exec_shell.c +++ b/lib/exec_shell.c @@ -42,9 +42,7 @@ void __attribute__((__noreturn__)) exec_shell(void) shellc = xstrdup(shell); shell_basename = basename(shellc); - arg0 = xmalloc(strlen(shell_basename) + 2); - arg0[0] = '-'; - strcpy(arg0 + 1, shell_basename); + xasprintf(&arg0, "-%s", shell_basename); execl(shell, arg0, (char *)NULL); errexec(shell);