diff options
Diffstat (limited to 'lib/libevent/buffer.c')
-rw-r--r-- | lib/libevent/buffer.c | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/lib/libevent/buffer.c b/lib/libevent/buffer.c index 4a1ac9f7a29..2c706bb4ff0 100644 --- a/lib/libevent/buffer.c +++ b/lib/libevent/buffer.c @@ -1,4 +1,4 @@ -/* $OpenBSD: buffer.c,v 1.12 2006/12/21 02:28:47 krw Exp $ */ +/* $OpenBSD: buffer.c,v 1.13 2007/02/04 18:59:12 millert Exp $ */ /* * Copyright (c) 2002, 2003 Niels Provos <provos@citi.umich.edu> @@ -434,12 +434,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); |