[Asterisk-Dev] possible bug in pbx.c::substring() ?
Tilghman Lesher
tilghman at mail.jeffandtilghman.com
Mon Jan 16 12:33:22 MST 2006
On Monday 16 January 2006 06:20, Luigi Rizzo wrote:
> look at the following piece of code in pbx.c::substring() that
> deals with incorrect arguments.
>
> offset = -N means take the substring starting N positions from the
> end. In this case (which the test correctly identifies, the max
> length is -offset); however in the body the max length is incorrectly
> set to strlen(ret)+offset, while it should be -offset
>
> /* Detect too-long length */
> if ((offset < 0 && length > -offset) || (offset >= 0 &&
> offset+length > strlen(ret))) { if (offset >= 0)
> length = strlen(ret)-offset;
> else
> length = strlen(ret)+offset; /* XXX should be
> length = -offset */ }
>
>
> right ?
Try it. It actually doesn't make any difference. Both calculations
result in exactly the same resulting string.
--
Tilghman
More information about the asterisk-dev
mailing list