evbuffer_find fix from Dug Song

svn:r308
This commit is contained in:
Niels Provos 2007-01-06 02:25:50 +00:00
parent ba8289bea5
commit de4e25f1d0

View File

@ -432,12 +432,13 @@ evbuffer_find(struct evbuffer *buffer, const u_char *what, size_t len)
u_char *search = buffer->buffer;
u_char *p;
while ((p = memchr(search, *what, remain)) != NULL && remain >= len) {
while ((p = memchr(search, *what, remain)) != NULL) {
remain = buffer->off - (size_t)(search - buffer->buffer);
if (remain < len)
break;
if (memcmp(p, what, len) == 0)
return (p);
search = p + 1;
remain = buffer->off - (size_t)(search - buffer->buffer);
}
return (NULL);