fix undefined behavior from signed overflow in strstr and memmem