diff options
Diffstat (limited to 'buffer.c')
-rw-r--r-- | buffer.c | 8 |
1 files changed, 4 insertions, 4 deletions
@@ -12,7 +12,7 @@ | |||
12 | */ | 12 | */ |
13 | 13 | ||
14 | #include "includes.h" | 14 | #include "includes.h" |
15 | RCSID("$OpenBSD: buffer.c,v 1.22 2004/10/29 23:56:17 djm Exp $"); | 15 | RCSID("$OpenBSD: buffer.c,v 1.23 2005/03/14 11:46:56 markus Exp $"); |
16 | 16 | ||
17 | #include "xmalloc.h" | 17 | #include "xmalloc.h" |
18 | #include "buffer.h" | 18 | #include "buffer.h" |
@@ -78,7 +78,7 @@ buffer_append_space(Buffer *buffer, u_int len) | |||
78 | u_int newlen; | 78 | u_int newlen; |
79 | void *p; | 79 | void *p; |
80 | 80 | ||
81 | if (len > 0x100000) | 81 | if (len > BUFFER_MAX_CHUNK) |
82 | fatal("buffer_append_space: len %u not supported", len); | 82 | fatal("buffer_append_space: len %u not supported", len); |
83 | 83 | ||
84 | /* If the buffer is empty, start using it from the beginning. */ | 84 | /* If the buffer is empty, start using it from the beginning. */ |
@@ -97,7 +97,7 @@ restart: | |||
97 | * If the buffer is quite empty, but all data is at the end, move the | 97 | * If the buffer is quite empty, but all data is at the end, move the |
98 | * data to the beginning and retry. | 98 | * data to the beginning and retry. |
99 | */ | 99 | */ |
100 | if (buffer->offset > buffer->alloc / 2) { | 100 | if (buffer->offset > MIN(buffer->alloc, BUFFER_MAX_CHUNK)) { |
101 | memmove(buffer->buf, buffer->buf + buffer->offset, | 101 | memmove(buffer->buf, buffer->buf + buffer->offset, |
102 | buffer->end - buffer->offset); | 102 | buffer->end - buffer->offset); |
103 | buffer->end -= buffer->offset; | 103 | buffer->end -= buffer->offset; |
@@ -107,7 +107,7 @@ restart: | |||
107 | /* Increase the size of the buffer and retry. */ | 107 | /* Increase the size of the buffer and retry. */ |
108 | 108 | ||
109 | newlen = buffer->alloc + len + 32768; | 109 | newlen = buffer->alloc + len + 32768; |
110 | if (newlen > 0xa00000) | 110 | if (newlen > BUFFER_MAX_LEN) |
111 | fatal("buffer_append_space: alloc %u not supported", | 111 | fatal("buffer_append_space: alloc %u not supported", |
112 | newlen); | 112 | newlen); |
113 | buffer->buf = xrealloc(buffer->buf, newlen); | 113 | buffer->buf = xrealloc(buffer->buf, newlen); |