Skip to content

Commit 00fc5a2

Browse files
committed
MB-29287: Avoid ambiguity in ActiveStream cursor name
Handle the possible edge-case where the user-provided node-name plus counter could be ambiguous - from Aliaksey: Consider the following case. Lets say we replicate to two nodes here, one named 'node' the other one 'node1'. We create replication to node1 and the counter is 0. Then after some time replication to node is created when the counter is 10. Now you have two totally different replications using the same cursor. ns_server happens to put the bucket name in the end of the connection name. So it saves us from the case I described. But a malicious client could craft a name that causes this sort of conflict. This is very unlikely to occur, but not impossible; so for the sake of being completeness avoid this situation by inserting a fixed seperator between the user-provided name and the counter. Change-Id: Ie308a09d420d8275ed059e834c09684675f9f737 Reviewed-on: http://review.couchbase.org/93407 Well-Formed: Build Bot <[email protected]> Reviewed-by: Trond Norbye <[email protected]> Reviewed-by: Daniel Owen <[email protected]> Reviewed-by: Tim Bradgate <[email protected]> Tested-by: Build Bot <[email protected]>
1 parent f4982c3 commit 00fc5a2

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/dcp/stream.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@ ActiveStream::ActiveStream(EventuallyPersistentEngine* e, dcp_producer_t p,
183183
payloadType((flags & DCP_ADD_STREAM_FLAG_NO_VALUE) ? KEY_ONLY :
184184
KEY_VALUE),
185185
lastSentSnapEndSeqno(0), chkptItemsExtractionInProgress(false),
186-
cursorName(n + std::to_string(cursorUID.fetch_add(1))) {
186+
cursorName(n + '/' + std::to_string(cursorUID.fetch_add(1))) {
187187
const char* type = "";
188188
if (flags_ & DCP_ADD_STREAM_FLAG_TAKEOVER) {
189189
type = "takeover ";

0 commit comments

Comments
 (0)