File tree Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Expand file tree Collapse file tree 2 files changed +30
-0
lines changed Original file line number Diff line number Diff line change @@ -104,6 +104,13 @@ public function __construct(LoopInterface $loop = null)
104
104
public function open ($ filename , $ flags = null )
105
105
{
106
106
$ filename = $ this ->resolve ($ filename );
107
+
108
+ if (\strpos ($ filename , "\0" ) !== false ) {
109
+ return \React \Promise \reject (new \InvalidArgumentException (
110
+ 'Invalid argument (filename) given: Invalid null byte in your SQLite database file path '
111
+ ));
112
+ }
113
+
107
114
return $ this ->useSocket ? $ this ->openSocketIo ($ filename , $ flags ) : $ this ->openProcessIo ($ filename , $ flags );
108
115
}
109
116
Original file line number Diff line number Diff line change @@ -134,6 +134,29 @@ public function testOpenInvalidPathRejects($flag)
134
134
$ loop ->run ();
135
135
}
136
136
137
+ /**
138
+ * @dataProvider provideSocketFlags
139
+ * @param bool $flag
140
+ */
141
+ public function testOpenInvalidPathWithNullByteReadAsOneByteWillReject ($ flag )
142
+ {
143
+ $ loop = \React \EventLoop \Factory::create ();
144
+ $ factory = new Factory ($ loop );
145
+
146
+ $ ref = new \ReflectionProperty ($ factory , 'useSocket ' );
147
+ $ ref ->setAccessible (true );
148
+ $ ref ->setValue ($ factory , $ flag );
149
+
150
+ $ promise = $ factory ->open ("test \0.db " );
151
+
152
+ $ promise ->then (
153
+ null ,
154
+ $ this ->expectCallableOnceWith ($ this ->isInstanceOf ('InvalidArgumentException ' ))
155
+ );
156
+
157
+ $ loop ->run ();
158
+ }
159
+
137
160
/**
138
161
* @dataProvider provideSocketFlags
139
162
* @param bool $flag
You can’t perform that action at this time.
0 commit comments