-
Notifications
You must be signed in to change notification settings - Fork 237
Closed
Description
Bug Description
Hi, we find 151 input files and pcre2test could not terminate in 60 minutes while processing them, which may trigger some dead loops.
We select one simplest input file (decompress it) to analyze the bug and the results of our analysis are as follows. (Maybe there are other situations.)
Bug Analysis
We find an endless looping may in pcre2test.c:6860
With the input (decompress it).
--
\[X]{-10}
The relevant code snippet is as follows.
li = strtol((const char *)p, &endptr, 10);
i = (int32_t)li;
if (i-- == 0) {// ...}
// ...
replen = CAST8VAR(q) - start_rep;
needlen += replen * i;
if (needlen >= dbuffer_size)
{
// ...
6860: while (needlen >= dbuffer_size) dbuffer_size *= 2;
// ...
}p= "-10",li=i= -10- With
i--,i= -11 - With
replen = CAST8VAR(q) - start_rep;,replen= 1 - With initial value 10 and
needlen += replen * i,needlen= -1 = 2 ^ 64 -1, as type(needlen) =size_t - Then an endless looping occurs in line: 6860.
- In fact, the
whileentry condition is vulnerable. With needlen ∈ [ 2 ^ 63, 2 ^ 64), thewhileis very easy to trap into endless looping.
- In fact, the
How to reproduce
- Download the pcre2 source code with the official link and build it.
./autogen.shCC=gcc CXX=g++ ./configure --disable-shared --prefix=...make -j 8make install
- Executing prec2test with the provided input files
- Decompress the zip to get all the input files.
cd <your install directory>./bin/pcre2test <any input file in the zip>
Metadata
Metadata
Assignees
Labels
No labels