Skip to content
This repository was archived by the owner on Dec 23, 2021. It is now read-only.

Commit 2052978

Browse files
committed
Merged pull request #69
2 parents 291b199 + 64a9745 commit 2052978

File tree

2 files changed

+24
-0
lines changed

2 files changed

+24
-0
lines changed

ext_mongodb.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -657,6 +657,10 @@ final class Binary implements Type, \Serializable
657657

658658
public function __construct(private string $data, private int $type)
659659
{
660+
if ( $type < 0 || $type > 255 )
661+
{
662+
throw new \MongoDB\Driver\Exception\InvalidArgumentException( "Expected type to be an unsigned 8-bit integer, {$type} given" );
663+
}
660664
}
661665

662666
public function getType()
@@ -758,6 +762,14 @@ final class Timestamp implements Type, \Serializable
758762

759763
public function __construct(private int $increment, private int $timestamp)
760764
{
765+
if ( $increment < 0 || $increment > 4294967295 )
766+
{
767+
throw new \MongoDB\Driver\Exception\InvalidArgumentException( "Expected increment to be an unsigned 32-bit integer, {$increment} given" );
768+
}
769+
if ( $timestamp < 0 || $timestamp > 4294967295 )
770+
{
771+
throw new \MongoDB\Driver\Exception\InvalidArgumentException( "Expected timestamp to be an unsigned 32-bit integer, {$timestamp} given" );
772+
}
761773
}
762774

763775
public function __toString() : string

src/MongoDB/Driver/WriteConcern.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,18 @@ void HHVM_METHOD(MongoDBDriverWriteConcern, __construct, const Variant &w, const
9494
throw MongoDriver::Utils::throwInvalidArgumentException((char*) wtimeout_error.toString().c_str());
9595
}
9696

97+
if (wtimeout_int > INT32_MAX) {
98+
StringBuffer buf;
99+
100+
buf.printf(
101+
"Expected wtimeout to be <= %d, %ld given",
102+
INT32_MAX,
103+
wtimeout_int
104+
);
105+
Variant wtimeout_error = buf.detach();
106+
throw MongoDriver::Utils::throwInvalidArgumentException((char*) wtimeout_error.toString().c_str());
107+
}
108+
97109
mongoc_write_concern_set_wtimeout(data->m_write_concern, wtimeout_int);
98110
}
99111

0 commit comments

Comments
 (0)