off by -1 problem in trim_string

Jeremy Allison jeremy at valinux.com
Thu May 10 21:18:19 GMT 2001


Ben Winslow wrote:
> 
> trim_string() in lib/util_str.c seems to have a potential off by -1
> problem that my config file tickled a few times.  I've attached a patch
> to fix the problem.  Basically, in this code:
>     if ( back && back_len > 1 && s_len > back_len) {
>          char   *bP     = sP + s_len - back_len;
>          long   b_len   = s_len;
> bP can be set to sP - 1 (sP being the start of s) if s_len = 1 and
> back_len = 2 (which is what happened in my case).  I didn't actually
> track down the offending call to the function (I can if anyone cares),
> but I suspect it was something in the config file parser.

Fixed it, thanks.

Jeremy.

-- 
--------------------------------------------------------
Buying an operating system without source is like buying
a self-assembly Space Shuttle with no instructions.
--------------------------------------------------------




More information about the samba-technical mailing list