Skip site navigation (1) Skip section navigation (2)

Re: usermap regexp support

From: Magnus Hagander <magnus(at)hagander(dot)net>
To: Gianni Ciolli <gianni(dot)ciolli(at)2ndquadrant(dot)it>
Cc: PG Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: usermap regexp support
Date: 2008-11-11 13:59:01
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-hackers
Gianni Ciolli wrote:
> On Tue, Oct 28, 2008 at 08:59:53PM +0100, Magnus Hagander wrote:
>> The attached patch tries to implement regexp support in the usermaps
>> (pg_ident.conf).
> Hi Magnus,
> I am currently reviewing your patch.


Thanks for the review!

> I found out that the execution of
>       pfree(regexp_pgrole);
> (there's only one such line in your patch) might raise on the current
> HEAD the following message
>       WARNING:  detected write past chunk end in Postmaster 0x9b13650

Yes, that's a stupid bug:
-                       /* length: original length minus length of \1
plus length of match */
-                       regexp_pgrole =
+                       /* length: original length minus length of \1
plus length of match plus null terminator */
+                       regexp_pgrole = palloc0(strlen(file_pgrole) - 2
+ (matches[1].rm_eo-matches[1].rm_so) + 1);

Two bugs: the length calculation used the start of the string vs the
start of the string, instead of end vs start. And there was no room for
the NULL terminator.

Attached is an updated version of the patch that fixes this.


Attachment: ident_regexp.patch
Description: text/x-diff (4.5 KB)

In response to


pgsql-hackers by date

Next:From: Sergey KonoplevDate: 2008-11-11 14:03:44
Subject: Re: Very slow queries w/ NOT IN preparation (seems like a bug, test case)
Previous:From: Alvaro HerreraDate: 2008-11-11 13:44:12
Subject: Re: Duplicated docs on libpq parameters

Privacy Policy | About PostgreSQL
Copyright © 1996-2017 The PostgreSQL Global Development Group