[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: (ITS#6338) dnParent(x, x) can remove \0-termination

masarati@aero.polimi.it writes:
>>     struct berval x = BER_BVC("cn=foo");
>>     dnParent(x, x);
>> keeps x.bv_val pointing at "cn=foo" instead of at the \0
>> behind it.  bv_len is correctly set to 0 though.
> Could be sort of intentional.  As far as I remember, dnParent() is 
> supposed to leave the second argument untouched, as it is often used
> on read-only data.

s/second/first/, but yes.  With pdn=dn though (both args equal), the
code first reset pdn->bv_val and then used that value.  Swapping it
makes more sense, and ensures that the output value is independent of
whether or not pdn == dn.

> Probably, the most appropriate fix consists in passing 
> a temporary as the first argument.

No, the comment above the function says that pdn can be == dn.