https://gcc.gnu.org/bugzilla/show_bug.cgi?id=78433

--- Comment #8 from Dominik Vogt <vogt at linux dot vnet.ibm.com> ---
This code from maybe_script_execute() writes past the allocated array bounds:

  /* Construct an argument list for the shell. */
  char *new_argv[argc + 1];
                 ^^^^^^^^
  new_argv[0] = (char *) _PATH_BSHELL;
  new_argv[1] = (char *) file;
  if (argc > 1)
    memcpy (new_argv + 2, argv + 1, argc * sizeof(char *));
                    ^^^^^          ^^^^^^
  else
    new_argv[2] = NULL;
            ^^^

Before the patch, Gcc often allocated several bytes more than necessary so that
many off-by-one bugs went unnoticed.

Reply via email to