summaryrefslogtreecommitdiffhomepage
path: root/buffer.c
diff options
context:
space:
mode:
authorMatt Johnston <matt@ucc.asn.au>2004-08-12 16:41:58 +0000
committerMatt Johnston <matt@ucc.asn.au>2004-08-12 16:41:58 +0000
commit8e1ec24f55be1a9af2595a58bb4b805bebd7fa9d (patch)
tree0b54a905a49358adc37ce32e3e80239dd6ebd736 /buffer.c
parent538bc5a09e8a7aa6fdc7f38f0bac649efd6bd264 (diff)
Merging in the changes from 0.41-0.43 main Dropbear tree
--HG-- extra : convert_revision : 4c3428781bc8faf0fd7cadd7099fbd7f4ea386e7
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/buffer.c b/buffer.c
index 7181fca..df608d9 100644
--- a/buffer.c
+++ b/buffer.c
@@ -34,8 +34,8 @@
#define BUF_MAX_INCR 1000000000
#define BUF_MAX_SIZE 1000000000
-/* avoid excessively large numbers, > 5000 bit */
-#define BUF_MAX_MPINT (5000 / 8)
+/* avoid excessively large numbers, > ~8192 bits */
+#define BUF_MAX_MPINT (8240 / 8)
/* Create (malloc) a new buffer of size */
buffer* buf_new(unsigned int size) {
@@ -76,7 +76,8 @@ void buf_burn(buffer* buf) {
}
-/* resize a buffer, pos and len will be repositioned if required */
+/* resize a buffer, pos and len will be repositioned if required when
+ * downsizing */
void buf_resize(buffer *buf, unsigned int newsize) {
if (newsize > BUF_MAX_SIZE) {
@@ -151,6 +152,8 @@ void buf_incrpos(buffer* buf, int incr) {
/* Get a byte from the buffer and increment the pos */
unsigned char buf_getbyte(buffer* buf) {
+ /* This check is really just ==, but the >= allows us to check for the
+ * assert()able case of pos > len, which should _never_ happen. */
if (buf->pos >= buf->len) {
dropbear_exit("bad buf_getbyte");
}