aboutsummaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorJulien Chaffraix <julien.chaffraix@gmail.com>2010-09-10 00:22:40 -0700
committerDaniel Stenberg <daniel@haxx.se>2010-09-22 23:34:36 +0200
commitfbb38de415b7bb7d743e53a7b4b887ffb12b3e5b (patch)
tree150d3b2c14a0b9f40954b6469c5a632a7920e0cf /lib
parent0006cdddee80718cb83aab0f1b544d79f1262159 (diff)
security.c: buffer_read various fixes.
Tighten the type of the |data| parameter to avoid a cast. Also made it const as we should not modify it. Added a DEBUGASSERT on the size to be written while changing it.
Diffstat (limited to 'lib')
-rw-r--r--lib/security.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/lib/security.c b/lib/security.c
index e9f8ea02f..c79128abd 100644
--- a/lib/security.c
+++ b/lib/security.c
@@ -180,11 +180,13 @@ static CURLcode read_data(struct connectdata *conn,
}
static size_t
-buffer_read(struct krb4buffer *buf, void *data, size_t len)
+buffer_read(struct krb4buffer *buf, const char *data, size_t len)
{
- if(buf->size - buf->index < len)
- len = buf->size - buf->index;
- memcpy(data, (char*)buf->data + buf->index, len);
+ size_t buf_capacity = buf->size - buf->index;
+ DEBUGASSERT(buf->size > buf->index);
+ if(buf_capacity < len)
+ len = buf_capacity;
+ memcpy(buf, data, len);
buf->index += len;
return len;
}