MB-9766: Don't assume that the string is zero terminated

Change-Id: I7804843d3e411000806c7f6532a7dab3835100ca
Reviewed-on: http://review.couchbase.org/31233
Reviewed-by: Michael Wiederhold <mike@couchbase.com>
Tested-by: Michael Wiederhold <mike@couchbase.com>