Bug 30009 - unterminated options list in benchtest
Summary: unterminated options list in benchtest
Status: RESOLVED FIXED
Alias: None
Product: glibc
Classification: Unclassified
Component: build (show other bugs)
Version: unspecified
: P2 minor
Target Milestone: 2.41
Assignee: Florian Weimer
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2023-01-17 12:45 UTC by Gabriel Valky
Modified: 2024-08-09 15:18 UTC (History)
2 users (show)

See Also:
Host:
Target:
Build:
Last reconfirmed:
fweimer: security-


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Gabriel Valky 2023-01-17 12:45:56 UTC
Component: benchtests
Overview: Tests are crashing while printing CLI help
Steps to reproduce:
  make bench-build && benchtests/bench-bzero --help

Code: 
  Options list is on two locations
  1. support/support_test_main.c:42

    static const struct option default_options[] =
    {
      TEST_DEFAULT_OPTIONS
      { NULL, 0, NULL, 0 }
    };

  2. support/test-driver.c:153

    #ifdef CMDLINE_OPTIONS
      struct option options[] =
        {
          CMDLINE_OPTIONS
          TEST_DEFAULT_OPTIONS
        };
      test_config.options = &options;
    #endif

  The first one is properly terminated, whereas the later one is not.

Suggested fix: Add terminator in support/test-driver.c:153, after this change the CLI help is printed out without segfault.

    #ifdef CMDLINE_OPTIONS
      struct option options[] =
        {
          CMDLINE_OPTIONS
          TEST_DEFAULT_OPTIONS
          { NULL, 0, NULL, 0 }
        };
      test_config.options = &options;
    #endif
Comment 1 Florian Weimer 2024-08-09 15:18:06 UTC
Sorry, didn't notice this bug before. Fixed for glibc 2.41 via:

commit c2a474f4617ede7a8bf56b7257acb37dc757b2d1
Author: Florian Weimer <fweimer@redhat.com>
Date:   Fri Aug 9 17:01:17 2024 +0200

    support: Add options list terminator to the test driver
    
    This avoids crashes if a test is passed unknown options.
    
    Reviewed-by: Adhemerval Zanella <adhemerval.zanella@linaro.org>