summaryrefslogtreecommitdiff
path: root/src/mongo/db/index_set.cpp
diff options
context:
space:
mode:
authorEliot Horowitz <eliot@10gen.com>2013-02-27 13:26:16 -0500
committerEliot Horowitz <eliot@10gen.com>2013-02-28 16:44:11 -0500
commitdd142e8324f977197107c9bbec62f4af3670aebd (patch)
tree13828779ae47562a09cbaecc3f21662cf5f770db /src/mongo/db/index_set.cpp
parentb91edafaec04c2b131a5bca03f05da55fa28c90a (diff)
downloadmongo-dd142e8324f977197107c9bbec62f4af3670aebd.tar.gz
SERVER-8758 - don't go past StringData end since it might not be null terminated
- fix $ handling in middle of string
Diffstat (limited to 'src/mongo/db/index_set.cpp')
-rw-r--r--src/mongo/db/index_set.cpp15
1 files changed, 12 insertions, 3 deletions
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)