The following issues were found
src/mongo/base/uuid_test.cpp
1 issues
Line: 53
}
}
TEST(UUIDTest, isUUIDStringTest) {
// Several valid strings
ASSERT(UUID::isUUIDString("00000000-0000-4000-8000-000000000000"));
ASSERT(UUID::isUUIDString("01234567-9abc-4def-9012-3456789abcde"));
ASSERT(UUID::isUUIDString("dddddddd-eeee-4fff-aaaa-bbbbbbbbbbbb"));
ASSERT(UUID::isUUIDString("A9A9A9A9-BEDF-4DD9-B001-222345716283"));
Reported by Cppcheck.
src/mongo/bson/bson_bm.cpp
1 issues
Line: 59
Column: 39
CWE codes:
327
Suggestion:
Use a more secure technique for acquiring random values
<< "433 W 43rd St"
<< "zip_code" << zip_code << "city"
<< "New York")
<< "random" << random << "phone_no" << phone_no << "long_string"
<< long_string);
}
} // namespace
void BM_arrayBuilder(benchmark::State& state) {
Reported by FlawFinder.
src/mongo/bson/bson_field_test.cpp
1 issues
Line: 38
using mongo::BSONField;
using mongo::BSONObj;
TEST(Assignment, Simple) {
BSONField<int> x("x");
BSONObj o = BSON(x << 5);
ASSERT_BSONOBJ_EQ(BSON("x" << 5), o);
}
Reported by Cppcheck.
src/mongo/bson/bson_obj_data_type_test.cpp
1 issues
Line: 40
Column: 5
CWE codes:
119
120
Suggestion:
Perform bounds checking, use functions that limit length, or ensure that the size is larger than the maximum possible length
namespace mongo {
TEST(BSONObjDataType, ConstDataTypeRangeBSON) {
char buf[1000] = {0};
DataRangeCursor drc(buf, buf + sizeof(buf));
{
BSONObjBuilder b;
Reported by FlawFinder.
src/mongo/bson/bson_validate_old.cpp
1 issues
Line: 81
Column: 43
CWE codes:
120
20
if ((_position + sizeof(N)) > _maxLength)
return false;
if (out) {
*out = ConstDataView(_buffer).read<LittleEndian<N>>(_position);
}
_position += sizeof(N);
return true;
}
Reported by FlawFinder.
src/mongo/bson/bsonobj.h
1 issues
Line: 430
Column: 41
CWE codes:
120
20
/** @return total size of the BSON object in bytes */
int objsize() const {
return ConstDataView(objdata()).read<LittleEndian<int>>();
}
/** performs a cursory check on the object's size only. */
template <typename Traits = DefaultSizeTrait>
bool isValid() const {
Reported by FlawFinder.
src/mongo/bson/bsonobjbuilder_test.cpp
1 issues
Line: 67
}
}
TEST(BSONObjBuilderTest, AppendInt64T) {
auto obj = BSON("a" << int64_t{5} << "b" << int64_t{1ll << 40});
ASSERT_EQ(obj["a"].type(), NumberLong);
ASSERT_EQ(obj["b"].type(), NumberLong);
ASSERT_EQ(obj["a"].Long(), 5);
ASSERT_EQ(obj["b"].Long(), 1ll << 40);
Reported by Cppcheck.
src/mongo/bson/mutable/mutable_bson_algo_test.cpp
1 issues
Line: 59
Document _doc;
};
TEST_F(DocumentTest, FindInEmptyObject) {
Element leftChild = doc().root().leftChild();
ASSERT_FALSE(leftChild.ok());
Element found = findElementNamed(leftChild, "X");
ASSERT_FALSE(found.ok());
ASSERT_EQUALS(&leftChild.getDocument(), &found.getDocument());
Reported by Cppcheck.
src/mongo/bson/oid_test.cpp
1 issues
Line: 40
using mongo::OID;
TEST(Equals, Simple) {
OID o1 = OID::gen();
ASSERT_EQUALS(o1, o1);
ASSERT_TRUE(o1 == o1);
ASSERT_EQUALS(o1.compare(o1), 0);
Reported by Cppcheck.
src/mongo/bson/simple_bsonobj_comparator_test.cpp
1 issues
Line: 62
<< "object was inserted successfully, but should have failed: " << obj.jsonString();
}
TEST(SimpleBSONObjContainerTest, SetIsDefaultConstructible) {
SimpleBSONObjSet set;
assertInsertSucceeds(set, BSON("x" << 1));
ASSERT_EQ(set.size(), 1UL);
assertInsertSucceeds(set, BSON("y" << 1));
assertInsertFails(set, BSON("x" << 1));
Reported by Cppcheck.