mirror of
https://github.com/libevent/libevent.git
synced 2025-01-31 09:12:55 +08:00
Do not allow chain length to expand indefinitely.
svn:r1007
This commit is contained in:
parent
ad7f1b4ae9
commit
3552ac1eb3
7
buffer.c
7
buffer.c
@ -640,6 +640,8 @@ evbuffer_readln(struct evbuffer *buffer, size_t *n_read_out,
|
||||
return (line);
|
||||
}
|
||||
|
||||
#define EVBUFFER_CHAIN_MAX_AUTO_SIZE 4096
|
||||
|
||||
/* Adds data to an event buffer */
|
||||
|
||||
int
|
||||
@ -680,8 +682,9 @@ evbuffer_add(struct evbuffer *buf, const void *data_in, size_t datlen)
|
||||
}
|
||||
|
||||
/* we need to add another chain */
|
||||
/* XXX Does this double the length of every successive chain? */
|
||||
to_alloc = chain->buffer_len << 1;
|
||||
to_alloc = chain->buffer_len;
|
||||
if (to_alloc <= EVBUFFER_CHAIN_MAX_AUTO_SIZE/2)
|
||||
to_alloc <<= 1;
|
||||
if (datlen > to_alloc)
|
||||
to_alloc = datlen;
|
||||
chain->next = evbuffer_chain_new(to_alloc);
|
||||
|
Loading…
x
Reference in New Issue
Block a user