[syslog-ng] [PATCH] patterndb: Fix test_patterndb crash when testing outside-of-rule db lookups.

Nix nix at esperi.org.uk
Tue Apr 8 01:18:09 CEST 2014


On 7 Apr 2014, Gergely Nagy uttered the following:

> Nick Alcock <nix at esperi.org.uk> writes:
>
>> First test_patterndb_tags_outside_of_rule() nulls out the messages pointer,
>> then it calls clean_pattern_db(), which unconditionally dereferences it.
>
> While I was under the impression that g_ptr_array_*() would handle a
> NULL ptr array,

It does... *iff* glib was compiled with --enable-debug: in that
situation, g_ptr_array_foreach() does a g_return_if_fail() on the array,
and does nothing if it's NULL.

But if you specify --disable-debug, -DG_DISABLE_CHECKS gets defined,
whereupon g_return_if_fail() et al compile down to nothing, and
g_ptr_array_foreach() promptly dereferences the null pointer repeatedly.
Boom. (I'm using glib 2.38.2, but this behaviour appears to be as old as
glib.)

> For the record, I never saw the crash, so perhaps it happens only with
> specific glib settings... Do you have any G_DEBUG or similar environment
> variables set? If not, can you tell me how your glib was compiled, or
> which distro this crash happens on?

I have the *lack* of an --enable-debug at glib compile time set. A lot
of distros appear to compile it with --enable-debug, but I don't think
it's entirely wise to rely on this.

-- 
NULL && (void)


More information about the syslog-ng mailing list