mirror of
https://github.com/libevent/libevent.git
synced 2025-01-09 00:56:20 +08:00
Fix a bug in the improved EOL_CRLF code
When searching for a CRLF, it would find an LF, then look for a preceding CR if not at the start of the buffer. That's fine when we're starting from the beginning of the buffer, but if we're starting at (say) byte 100, and we have that byte == LF, we shouldn't check for a CR at byte 99.
This commit is contained in:
parent
264c7b9600
commit
d927965f22
7
buffer.c
7
buffer.c
@ -1374,13 +1374,15 @@ evbuffer_search_eol(struct evbuffer *buffer,
|
||||
extra_drain = 2;
|
||||
break;
|
||||
}
|
||||
case EVBUFFER_EOL_CRLF:
|
||||
case EVBUFFER_EOL_CRLF: {
|
||||
ev_ssize_t start_pos = it.pos;
|
||||
/* Look for a LF ... */
|
||||
if (evbuffer_strchr(&it, '\n') < 0)
|
||||
goto done;
|
||||
extra_drain = 1;
|
||||
/* ... optionally preceeded by a CR. */
|
||||
if (it.pos < 1) break;
|
||||
if (it.pos == start_pos)
|
||||
break; /* If the first character is \n, don't back up */
|
||||
/* This potentially does an extra linear walk over the first
|
||||
* few chains. Probably, that's not too expensive unless you
|
||||
* have a really pathological setup. */
|
||||
@ -1392,6 +1394,7 @@ evbuffer_search_eol(struct evbuffer *buffer,
|
||||
extra_drain = 2;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case EVBUFFER_EOL_LF:
|
||||
if (evbuffer_strchr(&it, '\n') < 0)
|
||||
goto done;
|
||||
|
Loading…
x
Reference in New Issue
Block a user