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

strchr() vs. ber_bvchr()

Ive just committed a patch that should solve some of the issues I
recently had with strchr(), and strrchr(), used on bervals, i.e. the (in
many cases theoretical, but concrete in others) that the search goes
past the end of the logical value of the string if it's not null-
terminated.  This may result in wasted time, read-past-end-of-buffer
issues and, whenever not checked, in errors.

In few cases, when the string was surely null-terminated, I didn't
replace strchr() with ber_bvchr(); in all other occurences, I used
ber_bvchr() and ber_bvrchr() whenever appropriate.  Since memrchr()
seems to be a GNU extension, I also added a lutil_memrchr() replacement.

Please review; in detail, I think some review may be necessary in
slapd/syncrepl.c 1.225 -> 1.226 and in overlays/translucent.c 1.5 ->
1.6, where the original code was not that straightforward so I might
have overlooked its purpose.

The patched version passes all tests repeatedly, so it appears to be
functionally equivalent to the original.  It's supposed to be definitely
better when strrchr() is replaced by ber_bvrchr() because the end of the
string is known in advance.


Ing. Pierangelo Masarati
Responsabile Open Solution

SysNet s.n.c.
Via Dossi, 8 - 27100 Pavia - ITALIA
Office:   +39.02.23998309          
Mobile:   +39.333.4963172
Email:    pierangelo.masarati@sys-net.it