I am using strstr() to compare an XML response versus an expected response. On shorter tests, this has worked properly, but now on the larger strings I am seeing two buffers exactly equal one another, but strstr() is failing to catch it.
The XML string response I am failing on is 502 bytes in size, so I’m expecting strstr() to find an occurrence of a 502 byte string inside a 502 byte string.
Example:
if( strstr(msgPointer, xmlcheckstring) )
{
printf("Good response!\n");
}
else
{
printf("Bad response :(\n");
}
Where msgPointer points to my receive buffer and xmlcheckstring contains a constant string to check against. And again, this worked for smaller tests (~200 bytes in size).
I’m just curious if anyone has had any experience with this. Thanks,
FreeBSD can be a useful source if you want to check the implementation of standard C functions.
Their version of strstr will look very similar to other standard library implementations and confirms there are no limitations that’d affect the relatively small strings you’re dealing with.