mirror of
https://github.com/php/php-src.git
synced 2025-08-16 05:58:45 +02:00
Merge branch 'PHP-8.3'
This commit is contained in:
commit
09f5e7921e
2 changed files with 41 additions and 11 deletions
|
@ -26,6 +26,35 @@ function phpt_has_sslv3() {
|
|||
return $result;
|
||||
}
|
||||
|
||||
function phpt_extract_tls_records($rawData) {
|
||||
$records = [];
|
||||
$offset = 0;
|
||||
$dataLength = strlen($rawData);
|
||||
|
||||
while ($offset < $dataLength) {
|
||||
// Ensure there's enough data left for the header.
|
||||
if ($offset + 5 > $dataLength) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Extract the length of the current record.
|
||||
$length = unpack("n", substr($rawData, $offset + 3, 2))[1];
|
||||
|
||||
// Check if the total length is within the bounds of the rawData.
|
||||
if ($offset + 5 + $length > $dataLength) {
|
||||
break;
|
||||
}
|
||||
|
||||
// Extract the record and add it to the records array.
|
||||
$records[] = substr($rawData, $offset, 5 + $length);
|
||||
|
||||
// Move the offset past the current record.
|
||||
$offset += 5 + $length;
|
||||
}
|
||||
|
||||
return $records;
|
||||
}
|
||||
|
||||
/**
|
||||
* This is a singleton to let the wait/notify functions work
|
||||
* I know it's horrible, but it's a means to an end
|
||||
|
|
|
@ -63,25 +63,26 @@ $proxyCode = <<<'CODE'
|
|||
|
||||
$read = [$upstream, $conn];
|
||||
$applicationData = false;
|
||||
$i = 1;
|
||||
while (stream_select($read, $write, $except, 1)) {
|
||||
foreach ($read as $fp) {
|
||||
$data = stream_get_contents($fp);
|
||||
if ($fp === $conn) {
|
||||
fwrite($upstream, $data);
|
||||
} else {
|
||||
if ($data !== '' && $data[0] === chr(23)) {
|
||||
if (!$applicationData) {
|
||||
$applicationData = true;
|
||||
fwrite($conn, $data[0]);
|
||||
phpt_notify();
|
||||
sleep(1);
|
||||
fwrite($conn, substr($data, 1));
|
||||
foreach (phpt_extract_tls_records($data) as $record) {
|
||||
if ($record !== '' && $record[0] === chr(23)) {
|
||||
if (!$applicationData) {
|
||||
$applicationData = true;
|
||||
fwrite($conn, $record[0]);
|
||||
phpt_notify();
|
||||
sleep(1);
|
||||
fwrite($conn, substr($record, 1));
|
||||
} else {
|
||||
fwrite($conn, $record);
|
||||
}
|
||||
} else {
|
||||
fwrite($conn, $data);
|
||||
fwrite($conn, $record);
|
||||
}
|
||||
} else {
|
||||
fwrite($conn, $data);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue