aboutsummaryrefslogtreecommitdiff
path: root/buffer.c
diff options
context:
space:
mode:
authorjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-07-27 05:31:09 +0000
committerjames <james@e7ae566f-a301-0410-adde-c780ea21d3b5>2008-07-27 05:31:09 +0000
commitb551bec9bc298fbade6bfe5c009dd417c5abd95f (patch)
tree32249fa2ce87d093c56c7a3669593103d6e59dc2 /buffer.c
parentAdded a warning message when passwords are cached in memory. (diff)
downloadopenvpn-b551bec9bc298fbade6bfe5c009dd417c5abd95f.tar.xz
Added additional defensive programming to buffer.[ch] functions.
git-svn-id: http://svn.openvpn.net/projects/openvpn/branches/BETA21/openvpn@3128 e7ae566f-a301-0410-adde-c780ea21d3b5
Diffstat (limited to 'buffer.c')
-rw-r--r--buffer.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/buffer.c b/buffer.c
index 0fe9b61..dfaaaa1 100644
--- a/buffer.c
+++ b/buffer.c
@@ -42,6 +42,12 @@ array_mult_safe (const size_t m1, const size_t m2)
return (size_t) res;
}
+void
+buf_size_error (size_t size)
+{
+ msg (M_FATAL, "fatal buffer size error, size=%lu", (unsigned long)size);
+}
+
struct buffer
#ifdef DMALLOC
alloc_buf_debug (size_t size, const char *file, int line)
@@ -64,6 +70,8 @@ alloc_buf_gc (size_t size, struct gc_arena *gc)
#endif
{
struct buffer buf;
+ if (!buf_size_valid (size))
+ buf_size_error (size);
buf.capacity = (int)size;
buf.offset = 0;
buf.len = 0;