[Pkg-shadow-devel] Bug#276419: su appends the positional args to the command line
Nicolas François
Nicolas François , 276419@bugs.debian.org
Wed, 23 Mar 2005 23:46:30 +0100
--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Hi,
I'm sure you all want to see it;)
--
Nekral
--oyUTqETQ0mS9luUI
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="su.c.patch"
--- su.c.orig 2005-03-23 23:26:21.000000000 +0100
+++ su.c 2005-03-23 23:28:21.000000000 +0100
@@ -183,10 +183,6 @@
{
const char **args;
int argno = 1;
- char cmd[BUFSIZ];
- int cmd_len_left = sizeof(cmd) - 1;
-
- cmd[0] = '\0';
if (additional_args)
args = (const char **) xmalloc (sizeof (char *)
@@ -212,28 +208,10 @@
args[0] = Basename(shell);
if (command || additional_args)
args[argno++] = "-c";
- if (command) {
- if (strlen(command) > cmd_len_left) {
- fprintf(stderr, _("Command line args too long\n"));
- exit(1);
- }
- strcat(cmd, command);
- cmd_len_left -= strlen(command);
- }
+ if (command && command[0]) args[argno++] = command;
if (additional_args)
- for (; *additional_args; ++additional_args) {
- if ((strlen(*additional_args) + 1) > cmd_len_left) {
- fprintf(stderr, _("Command line args too long\n"));
- exit(1);
- }
- if (cmd[0]) {
- strcat(cmd, " ");
- cmd_len_left--;
- }
- strcat(cmd, *additional_args);
- cmd_len_left -= strlen(*additional_args);
- }
- if (cmd[0]) args[argno++] = cmd;
+ for (; *additional_args; ++additional_args)
+ args[argno++] = *additional_args;
args[argno] = NULL;
execv (shell, (char **) args);
fprintf (stderr, _("No shell\n"));
--oyUTqETQ0mS9luUI--