RCBC-33 Fix buffer overflow vulnerability

Change-Id: I773fc85cea41f82ebca5cafe30f5ea2d3aec0def
Reviewed-on: http://review.couchbase.org/15500
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
[backport] Pick up cookies from pending buffer unless node connected

Change-Id: Ifbd01a13400430f461982bad379e9cc576fc878e
Reviewed-on: http://review.couchbase.org/15503
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
[backport] Fix ringbuffer_is_continous()

https://groups.google.com/d/topic/couchbase/YXwbi8KL-nI/discussion

Change-Id: I0965ec70bd2b28e16723da31ae63a3af33416890
Reviewed-on: http://review.couchbase.org/15504
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Update meta for release 1.0.3

Change-Id: I92c5859264a5c7d6585f29c306e706d5fdb7475f
Reviewed-on: http://review.couchbase.org/15580
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
[backport] vbucket_found_incorrect_master() returns server index

Change-Id: Iab8f04fddfead656e0715e54705af7235dec1518
Reviewed-on: http://review.couchbase.org/15881
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
CCBC-64 Send the retry-packet to new server

Change-Id: I9f4fdf4e8ae07e695d3901fb01fc2bae2e3b025c
Reviewed-on: http://review.couchbase.org/15882
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
[CCBC-65] Memory leak in libcouchbase_create / libcouchbase_destroy

When the client calls libcouchbase_create and then later calls
libcouchbase_destroy, some memory is leaked. For a client with many threads
that open and close couchbase sessions, this will lead to memory exhaustion.
The leak is caused by the use of strdup() in setup_boostrap_hosts(). These
duplicated strings are not free'd in libcouchbase_destroy. The leak can be
seen by using valgrind.

Thanks to James O'Connor

Change-Id: I376d0c767ddb9335feae6d7c28cd2e391209101c
Reviewed-on: http://review.couchbase.org/16032
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Always use cmd_log for server purge

Change-Id: Idd0057344030088c6d081bf3104401018e854c86
Reviewed-on: http://review.couchbase.org/15965
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
CCBC-62 Check for breakout condition after purging servers

Change-Id: I4899a923591141d354be2223baa0f882580d2670
Reviewed-on: http://review.couchbase.org/15966
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Fix ringbuffer_memcpy()

Change-Id: I3e34b3eb4bf5edd53f215f421fc88a93ece949ac
Reviewed-on: http://review.couchbase.org/16348
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
Tested-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Check return value of libcouchbase_apply_vbucket_config()

Change-Id: If47504d6dbe3d60ce28fa7e71498ea49e47389ca
Reviewed-on: http://review.couchbase.org/16132
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Do not consume the cookie for incomplete packet

Change-Id: I6de38a7a757c637a97a458d45df52bdf10c1c76a
Reviewed-on: http://review.couchbase.org/16350
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Give CouchbaseMock.jar a bit more time to warm up

Change-Id: Ia52a3143e77b3353d1b06e253aede29e58dc8a64
Reviewed-on: http://review.couchbase.org/16601
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Include <sys/type.h> header for libevent check

Change-Id: Ib81e72d98c0423475b6b64f0edfe122483e3ac57
Reviewed-on: http://review.couchbase.org/16643
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Be more specific about libevent version

Currently libcouchbase supports libevent >= 1.4
This means it won't compile on ubuntu 8.04

Change-Id: I1e1b9c9983d6b5d5dcc0afec77f4aee6d20306a5
Reviewed-on: http://review.couchbase.org/16644
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Fix config test: copy value in get callback

Change-Id: I6bfd19325410c359d770d586769515c66e40c6d2
Reviewed-on: http://review.couchbase.org/16645
Reviewed-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Implement ringbuffer_update()

This function allows to update the buffer with given bytearray either at
READ head or at WRITE. It is useful for updating the "peeked" packets. For
more details see unit tests.

Change-Id: I2c7f13a3cfd027550b8c072c3d5e3762441b22a9
Reviewed-on: http://review.couchbase.org/16580
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Reviewed-by: Mordechai Nunberg <mnunberg@haskalah.org>
Reviewed-by: Trond Norbye <trond.norbye@gmail.com>
Update metadata for release 1.0.4

Change-Id: I39fb26207e2caf05878e0ff6b0bb2cf92636b37e
Reviewed-on: http://review.couchbase.org/16650
Tested-by: Sergey Avseyev <sergey.avseyev@gmail.com>
Reviewed-by: Matt Ingenthron <matt@couchbase.com>
Merge branch 'release10'

* release10:
  Update metadata for release 1.0.4
  Implement ringbuffer_update()
  Fix config test: copy value in get callback
  Be more specific about libevent version
  Include <sys/type.h> header for libevent check
  Give CouchbaseMock.jar a bit more time to warm up
  Do not consume the cookie for incomplete packet
  Check return value of libcouchbase_apply_vbucket_config()
  Fix ringbuffer_memcpy()
  CCBC-62 Check for breakout condition after purging servers
  Always use cmd_log for server purge
  [CCBC-65] Memory leak in libcouchbase_create / libcouchbase_destroy
  CCBC-64 Send the retry-packet to new server
  [backport] vbucket_found_incorrect_master() returns server index
  Update meta for release 1.0.3
  [backport] Fix ringbuffer_is_continous()
  [backport] Pick up cookies from pending buffer unless node connected
  RCBC-33 Fix buffer overflow vulnerability

Conflicts:
	configure.ac
	packaging/deb/changelog
	packaging/rpm/libcouchbase.spec.in
	src/event.c
	src/instance.c
	src/ringbuffer.c
	src/ringbuffer.h
	src/server.c
	tests/ringbuffer-test.c

Change-Id: Iaa7fc7f99d2d574d0a1e394536c80791450e5f49
Reformat tests

Change-Id: Iad4d69d6e2c06f732ea588bafb44c4876b5dded1