Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix filename limit in unit-test harness #7

Open
abrunnin-xilinx opened this issue Mar 19, 2024 · 0 comments
Open

Fix filename limit in unit-test harness #7

abrunnin-xilinx opened this issue Mar 19, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@abrunnin-xilinx
Copy link
Contributor

The test harnesses all have a maximum length of the filename hardcoded in (512) but don't protect against overrunning this.
e.g. in ut_arista7150_ts.c :

  suite_add_tcase(s, tc_node);
  SRunner *sr = srunner_create(s);
  const char *progname;
  char logfile[512];

  progname = strrchr(argv[0], '/');
  if (progname) {
    progname++;
  } else {
    progname = argv[0];
  }
  snprintf(logfile, sizeof(logfile), "%s.out", progname);

  srunner_set_log(sr, logfile);
  srunner_run_all(sr, CK_VERBOSE);
  number_failed = srunner_ntests_failed(sr);
  srunner_free(sr);

We ought to check the output code from snprintf. It's almost certainly not a problem in practice, but we ought to do the right thing.

@abrunnin-xilinx abrunnin-xilinx added bug Something isn't working good first issue Good for newcomers labels Mar 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

1 participant