Re: Subject: Memory Leak vulnerability in reftable/readwrite_test.c
- From
- H Z <shiyuyuranzh@gmail.com>
- Date
- Mar 1, 2025, 06:10 UTC
- Message-ID
- <CAAJd+fbNhGa5Pe4x-_rbwXVoye9uBD45zoJtu7riiW7GfnU1Cg@mail.gmail.com>
- In-Reply-To
- <CAAJd+fZSUiiUm05D_eO3HS7p=WoxAWSZo51dUNjyGjUNJBvyGg@mail.gmail.com>
Also, here's the code path that leads to that memory leak vulnerability, which I've represented with an image.
H Z <shiyuyuranzh@gmail.com> 于2025年3月1日周六 14:07写道:
Show 20 quoted lines
> > Hi, I have found a potential memory leak bug in > reftable/readwrite_test.c and would like to report it to the > maintainers. Can you please help me to check it? Thank you for your > effort and patience! > > Below is the execution sequence of the program that may produce the bug. > > First, in file src/wrapper.c, function xstrdup allocates memory at > line 40 and returns at line 43. > Second, in the file reftable/reader.c, the function init_reader calls > the function xstrdup on line 202 to allocate memory for r->name, which > is the formal parameter of the function init_reader. > Third, in file reftable/readwrite_test.c, function > test_corrupt_table_empty calls function init_reader on line 935 with > &rd passed as the first argument, causing rd->name to be allocated > memory. rd->name is not freed, which would cause the memory leak > vulnerability. > > Thank you very much for reading and I look forward to hearing from you!