Skip to content

fix(tools): fix NULL pointer dereference in output_fname allocation and set output_fname to NULL after freeing to prevent dangling pointer#28

Open
vahagavagyan wants to merge 2 commits into
amd:amd-fftwfrom
vahagavagyan:fix-null-deref-output-fname
Open

fix(tools): fix NULL pointer dereference in output_fname allocation and set output_fname to NULL after freeing to prevent dangling pointer#28
vahagavagyan wants to merge 2 commits into
amd:amd-fftwfrom
vahagavagyan:fix-null-deref-output-fname

Conversation

@vahagavagyan
Copy link
Copy Markdown

Description

This PR fixes a potential NULL pointer dereference vulnerability in fftw-wisdom.c (or benchmark utility) inside the handling of the -o flag.

Missing validation

The current implementation calls strcpy(output_fname, my_optarg); immediately after calling bench_malloc(), without verifying if the memory allocation succeeded. If bench_malloc returns NULL due to memory exhaustion, it causes a crash (Segmentation Fault).

Changes

  • Added a validation check right after bench_malloc.
  • Handles allocation failure by printing an error and exiting gracefully.
  • Explicitly nullified output_fname after bench_free to avoid potential dangling pointer issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant