When not explictly given --enable-runtime/--enable-builtin,
./configure tries to first detect libidn2, then libicu, then
libidn. If none found, it fals back to --disable-runtime and
--disable-builtin.
Reported-by: Chun-wei Fan
Visual Studio does not come with unistd.h, so only include it when we
have HAVE_UNISTD_H. It also does not like including locale.h within
main() for some reason, so include that with the other system headers.
fmemopen() is a function that is only provided with *NIX systems, so we
ought to check for its presence in order to build and run the tests
in fuzz/ fully, otherwise, we just skip the tests.
Also include headers according to how they are found, and add fallbacks
for Visual Studio that do not have stdint.h yet.
Introduce a macro, PSL_PUBLIC, which is defined as nothing by default,
which can be used by the compiler to instruct the linker to export the
public symbols, such as __declspec (dllexport) on Visual Studio.
Include the Windows/Winsock2 counterparts of the networking headers on
Windows and avoid including *NIX-specific headers on Windows.
Also remove the small bits of C99isms from the code.
Large inputs on psl_registrable_domain() and psl_unregistrable_domain()
suffer from a O(N^2) behavior. This change limits N to avoid excessive
CPU usage.
At the same time we limit the fuzz corpora size to 64k which is far more
then we expect any real life domain to be.
Reported-by: OSS-Fuzz
When writing a wrapper around LibPSL in a different language it is
important that libpsl provide functions to free any memory that it
allocates. Without this, it is impossible to correctly free the memory
allocated by psl_str_to_utf8lower() function since in other languages
one may not have access to the same free() call from libc.