ironbee/ironbee — pull request #54 by crustymonkey (2014-09-10 23:39:21+00:00)
Title: Fix ib_strstr to actually work correctly when the haystack is smaller than the needle

There is a bug here wherein, if the haystack is smaller than the needle (strlen), then imax will get set to the 2's complement of the negative number and this function will wander through a large amount of system ram byte by byte until it will (probably) match whatever you are looking for anyway and return NULL.

TL;DR: Without this check, you end up with a buffer overflow and an incorrect return value.