From dd142e8324f977197107c9bbec62f4af3670aebd Mon Sep 17 00:00:00 2001 From: Eliot Horowitz Date: Wed, 27 Feb 2013 13:26:16 -0500 Subject: SERVER-8758 - don't go past StringData end since it might not be null terminated - fix $ handling in middle of string --- src/mongo/db/index_set.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'src/mongo/db/index_set.cpp') diff --git a/src/mongo/db/index_set.cpp b/src/mongo/db/index_set.cpp index dce6f6d516e..4d7cb62a759 100644 --- a/src/mongo/db/index_set.cpp +++ b/src/mongo/db/index_set.cpp @@ -76,11 +76,20 @@ namespace mongo { continue; } + if ( i + 1 == fullName.size() ) { + // ends with '.' + buf << c; + continue; + } + // check for ".$", skip if present if ( fullName[i+1] == '$' ) { - i++; - modified = true; - continue; + // only do this if its not something like $a + if ( i + 2 >= fullName.size() || fullName[i+2] == '.' ) { + i++; + modified = true; + continue; + } } // check for ".###" for any number of digits (no letters) -- cgit v1.2.1