[PATCH v12 1/4] elf: Add la_activity during application exit

Adhemerval Zanella adhemerval.zanella@linaro.org
Wed Jan 26 12:18:36 GMT 2022



On 26/01/2022 08:42, Florian Weimer wrote:
> * Adhemerval Zanella via Libc-alpha:
> 
>> +static int
>> +do_test (int argc, char *argv[])
>> +{
>> +  /* We must have either:
>> +     - One our fource parameters left if called initially:
>> +       + path to ld.so         optional
>> +       + "--library-path"      optional
>> +       + the library path      optional
>> +       + the application name  */
>> +  if (restart)
>> +    return handle_restart ();
>> +
>> +  char *spargv[9];
>> +  int i = 0;
>> +  for (; i < argc - 1; i++)
>> +    spargv[i] = argv[i + 1];
>> +  spargv[i++] = (char *) "--direct";
>> +  spargv[i++] = (char *) "--restart";
>> +  spargv[i] = NULL;
>> +  TEST_VERIFY_EXIT (i < array_length (spargv));
> 
> Sorry, I think this test is invalid because it happens after the
> out-of-bounds write.  I expect that compilers will eventually warn about
> that.

It seems that at least gcc 11 does not warn if the array is not large
enough.  Maybe this is better:

  char *spargv[9];
  TEST_VERIFY_EXIT (((argc - 1) + 3) < array_length (spargv));
  int i = 0;
  for (; i < argc - 1; i++)
    spargv[i] = argv[i + 1];
  spargv[i++] = (char *) "--direct";
  spargv[i++] = (char *) "--restart";
  spargv[i] = NULL;


More information about the Libc-alpha mailing list