Commit fbb38de4 authored by Julien Chaffraix's avatar Julien Chaffraix Committed by Daniel Stenberg
Browse files

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.
parent 0006cddd
Loading
Loading
Loading
Loading
+6 −4
Original line number Original line Diff line number Diff line
@@ -180,11 +180,13 @@ static CURLcode read_data(struct connectdata *conn,
}
}


static size_t
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)
  size_t buf_capacity = buf->size - buf->index;
    len = buf->size - buf->index;
  DEBUGASSERT(buf->size > buf->index);
  memcpy(data, (char*)buf->data + buf->index, len);
  if(buf_capacity < len)
    len = buf_capacity;
  memcpy(buf, data, len);
  buf->index += len;
  buf->index += len;
  return len;
  return len;
}
}