Skip to content

Commit

Permalink
Added test for #172
Browse files Browse the repository at this point in the history
  • Loading branch information
laruence committed May 7, 2022
1 parent f45e59d commit 45a87e3
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
1 change: 1 addition & 0 deletions package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,7 @@
<file name="053.phpt" role="test" />
<file name="054.phpt" role="test" />
<file name="bug74867.phpt" role="test" />
<file name="issue172.phpt" role="test" />
<file name="yar.inc" role="test" />
</dir>
<dir name="tools">
Expand Down
54 changes: 54 additions & 0 deletions tests/issue172.phpt
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
--TEST--
ISSUE #172 $provider/$token may not be nullbyte-terminated
--SKIPIF--
<?php
if (!extension_loaded("yar")) {
print "skip";
}
?>
--FILE--
<?php
include "yar.inc";

yar_server_start(<<<'PHP'
<?php
error_reporting(-1);
class Service_Provider {
protected function __auth($seq, $token) {
return strlen($token) == intval($seq);
}
public function info() {
return "okay";
}
}
$yar = new Yar_Server(new Service_Provider());
$yar->handle();
PHP
);

$token = str_pad("", 32, chr(127));
for ($seq = 0; $seq < 32; $seq++) {
$ticket = $token;
$ticket[$seq] = "\0";
Yar_Concurrent_Client::call(YAR_API_ADDRESS, "info",
NULL, NULL, NULL,
array(
YAR_OPT_PROVIDER=>"$seq",
YAR_OPT_TOKEN=>$ticket,
));
}

Yar_Concurrent_Client::loop(function($return, $callinfo) {
}, function($type, $error, $callinfo) {
echo $error;

});
?>
--CLEAN--
<?php
include 'yar.inc';
yar_server_cleanup();
?>
--EXPECT--

0 comments on commit 45a87e3

Please sign in to comment.