pcre2test: memory reports only compiled memory usage for code/data (#418)
authorCarlo Marcelo Arenas Belón <carenas@gmail.com>
Sun, 9 Jun 2024 15:22:15 +0000 (08:22 -0700)
committerMatthew Vernon <matthew@debian.org>
Fri, 15 Nov 2024 14:30:14 +0000 (14:30 +0000)
commitc015b7e5bbc8614dd1fddee06aeea9872f938d2c
treefa3558dec7774f3a47fd340ba5e5a432bf8a77f6
parent6b73d1405b3d04cabab2188589762de5ce8db64d
pcre2test: memory reports only compiled memory usage for code/data (#418)

Since 05aafb2 (Implement pcre2_set_max_pattern_compiled_length() and set
this limit in the fuzzer, 2024-04-24), the memory modifier has reported
the full size of the allocated "code" returned by `pcre2_compile`.

Problem is that the size of the structure used to hold that in memory also
depends on the platform ABI and even alignment by the compiler, and has
been therefore fragile to compare.

Revert to reporting only the additional memory that `pcre2_compile()` will
use for the compiled pattern (including any data tables) and make sure
that the limit provided with `pcre2_set_max_pattern_compiled_length()`
also avoid the internal struct overhead.

Fixes: #415
12 files changed:
doc/pcre2_set_max_pattern_compiled_length.3
src/pcre2_compile.c
src/pcre2test.c
testdata/testoutput8-16-2
testdata/testoutput8-16-3
testdata/testoutput8-16-4
testdata/testoutput8-32-2
testdata/testoutput8-32-3
testdata/testoutput8-32-4
testdata/testoutput8-8-2
testdata/testoutput8-8-3
testdata/testoutput8-8-4