diff options
author | Denis Grebennicov <denis.grebennicov@mongodb.com> | 2021-04-16 11:28:00 +0200 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-04-28 16:54:14 +0000 |
commit | bf5ff3ee53d1c85f5bc039735945a6a0cb512a93 (patch) | |
tree | f12ddd6e5afe56108b3948011f2c7f2788025771 /src/mongo/db/pipeline/document_source_skip.cpp | |
parent | 43941b42e08c6e7b8e5928cc4e6f94ace7667d74 (diff) | |
download | mongo-bf5ff3ee53d1c85f5bc039735945a6a0cb512a93.tar.gz |
SERVER-51072 $skip and $limit stages silently round large doubles to MAX_LONG
Diffstat (limited to 'src/mongo/db/pipeline/document_source_skip.cpp')
-rw-r--r-- | src/mongo/db/pipeline/document_source_skip.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/mongo/db/pipeline/document_source_skip.cpp b/src/mongo/db/pipeline/document_source_skip.cpp index b5c91d23059..7fa58be38ec 100644 --- a/src/mongo/db/pipeline/document_source_skip.cpp +++ b/src/mongo/db/pipeline/document_source_skip.cpp @@ -38,6 +38,7 @@ #include "mongo/db/pipeline/expression.h" #include "mongo/db/pipeline/expression_context.h" #include "mongo/db/pipeline/lite_parsed_document_source.h" +#include "mongo/util/str.h" namespace mongo { @@ -108,11 +109,10 @@ intrusive_ptr<DocumentSourceSkip> DocumentSourceSkip::create( intrusive_ptr<DocumentSource> DocumentSourceSkip::createFromBson( BSONElement elem, const intrusive_ptr<ExpressionContext>& pExpCtx) { - uassert(15972, - str::stream() << "Argument to $skip must be a number not a " << typeName(elem.type()), - elem.isNumber()); - auto nToSkip = elem.safeNumberLong(); - - return DocumentSourceSkip::create(pExpCtx, nToSkip); + const auto nToSkip = elem.parseIntegerElementToNonNegativeLong(); + uassert(5107200, + str::stream() << "invalid argument to $skip stage: " << nToSkip.getStatus().reason(), + nToSkip.isOK()); + return DocumentSourceSkip::create(pExpCtx, nToSkip.getValue()); } } // namespace mongo |