This is the mail archive of the gcc-bugs@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug middle-end/78433] [7 Regression] glibc posix/execvpe.c gets miscompiled with -O3


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.

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]