summaryrefslogtreecommitdiff
path: root/src/mongo/base/string_data.h
diff options
context:
space:
mode:
authorMark Benvenuto <mark.benvenuto@mongodb.com>2018-03-08 13:52:35 -0500
committerMark Benvenuto <mark.benvenuto@mongodb.com>2018-03-08 13:52:35 -0500
commite7dedcc3b42e3a601bd7080743d1e3c1d10e3cfa (patch)
tree52d41f3019672765b24152d87897c539f697af9f /src/mongo/base/string_data.h
parent8522318f0a92ce96b8d90e5bd5d52771b2d63c04 (diff)
downloadmongo-e7dedcc3b42e3a601bd7080743d1e3c1d10e3cfa.tar.gz
SERVER-22411 Refactor Windows Certificate PEM file loading
Diffstat (limited to 'src/mongo/base/string_data.h')
-rw-r--r--src/mongo/base/string_data.h9
1 files changed, 6 insertions, 3 deletions
diff --git a/src/mongo/base/string_data.h b/src/mongo/base/string_data.h
index 7d896e7ecaf..f05bdfb8ca3 100644
--- a/src/mongo/base/string_data.h
+++ b/src/mongo/base/string_data.h
@@ -140,7 +140,7 @@ public:
//
size_t find(char c, size_t fromPos = 0) const;
- size_t find(StringData needle) const;
+ size_t find(StringData needle, size_t fromPos = 0) const;
size_t rfind(char c, size_t fromPos = std::string::npos) const;
/**
@@ -278,7 +278,7 @@ inline size_t StringData::find(char c, size_t fromPos) const {
return static_cast<size_t>(static_cast<const char*>(x) - _data);
}
-inline size_t StringData::find(StringData needle) const {
+inline size_t StringData::find(StringData needle, size_t fromPos) const {
size_t mx = size();
size_t needleSize = needle.size();
@@ -287,9 +287,12 @@ inline size_t StringData::find(StringData needle) const {
else if (needleSize > mx)
return std::string::npos;
+ if (fromPos > size())
+ return std::string::npos;
+
mx -= needleSize;
- for (size_t i = 0; i <= mx; i++) {
+ for (size_t i = fromPos; i <= mx; i++) {
if (memcmp(_data + i, needle._data, needleSize) == 0)
return i;
}