Hi,

On Mon, Jun 25, Daniel Schneller wrote:
> This is the contents of the map file:
> -------- hostmap.txt ---------
> ^(.*)\.(.*)$ \1
> ------------------------------

Setting this to:
^(.*)\.(.*)$ \2

And I get
X-Distri-Mapped-From-Var: com

and with map_regm: ^(.*)\.(.*)\.(.*)$ \2.\3
(Host: www.distri.com)

I get X-Distri-Mapped-From-Var: distri.com

So it looks like only backref \1 has first char set to \000

> See the X-Distri-Mapped-From-Var header's value. It has what seems to be a 
> nul-byte
> instead of the first character of the domain name. The other X- headers
> before it are meant to narrow down where the bug actually happens.
> 
> It would appear that it is somehow related to passing a variable's value
> into the mapping function or its return from there. Interestingly, the
> issue does _not_ show when simply putting the variable value into a header
> (X-Distri-Direct-From-Var) or when calling the mapping function with the
> header lookup instead of the intermediate variable 
> (X-Distri-Mapped-From-Header).
> 
> 
> One more tidbit: If I change the mapping file to this:
> ------------------
> ^(.*)\.(.*)$ a\1
> ------------------
> 
> The generated header header changes to:
> ----------------------
> X-Distri-Mapped-From-Var: aaistri
> ----------------------
> 
> Looks like some off-by-one error?

AFAIK this works on 1.7.11 but seems to be broken on all 1.8.x.

I think this is the commit that breaks map_regm in this case:
b5997f740b21ebb197e10a0f2fe9dc13163e1772 (MAJOR: threads/map: Make
acls/maps thread safe).

If I revert this commit from pattern.c:pattern_exec_match
then the map_regm \1 backref seems to work.

-Jarno

-- 
Jarno Huuskonen

Reply via email to