Skip to content

Commit 11a272f

Browse files
committed
Replace 3 more warnings with errors
1 parent 4fdb417 commit 11a272f

4 files changed

+16
-27
lines changed

ext/mysqli/tests/ghsa-h35g-vwh6-m678-auth-message.phpt

+1-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,5 @@ print "done!";
3232
[*] Sending - Server Greeting: 580000000a352e352e352d31302e352e31382d4d6172696144420003000000473e3f6047257c6700fef7080200ff81150000000000000f0000006c6b55463f49335f686c6431006d7973716c5f6e61746976655f70617373776f7264
3333
[*] Received: 6900000185a21a00000000c0080000000000000000000000000000000000000000000000726f6f7400006d7973716c5f6e61746976655f70617373776f7264002c0c5f636c69656e745f6e616d65076d7973716c6e640c5f7365727665725f686f7374093132372e302e302e31
3434
[*] Sending - Malicious OK Auth Response [Extract heap through buffer over-read]: 0900000200000002000000fcff
35-
36-
Warning: mysqli::__construct(): OK packet message length is past the packet size in %s on line %d
37-
Unknown error while trying to connect via tcp://127.0.0.1:50001
35+
OK packet message length is past the packet size
3836
done!

ext/mysqli/tests/ghsa-h35g-vwh6-m678-def.phpt

+5-8
Original file line numberDiff line numberDiff line change
@@ -19,12 +19,10 @@ $conn = new mysqli($servername, $username, $password, "", $port);
1919

2020
echo "[*] Running query on the fake server...\n";
2121

22-
$result = $conn->query("SELECT * from users");
23-
24-
if ($result) {
25-
$all_fields = $result->fetch_fields();
26-
var_dump($result->fetch_all(MYSQLI_ASSOC));
27-
var_dump(get_object_vars($all_fields[0])["def"]);
22+
try {
23+
$result = $conn->query("SELECT * from users");
24+
} catch (mysqli_sql_exception $exception) {
25+
echo $exception->getMessage() . PHP_EOL;
2826
}
2927

3028
$conn->close();
@@ -42,6 +40,5 @@ print "done!";
4240
[*] Running query on the fake server...
4341
[*] Received: 140000000353454c454354202a2066726f6d207573657273
4442
[*] Sending - Malicious Tabular Response [Extract heap through buffer over-read]: 01000001011e0000020164016401640164016401640c3f000b000000030350000000fd000001aa05000003fe00002200040000040135017405000005fe00002200
45-
46-
Warning: mysqli::query(): Protocol error. Server sent default for unsupported field list (mysqlnd_wireprotocol.c:%d) in %s on line %d
43+
Server sent default for unsupported field list
4744
done!

ext/mysqli/tests/ghsa-h35g-vwh6-m678-filename.phpt

+7-5
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,12 @@ $process->wait();
1717
$conn = new mysqli($servername, $username, $password, "", $port);
1818
echo "[*] Running query on the fake server...\n";
1919

20-
$result = $conn->query("SELECT * from users");
20+
try {
21+
$result = $conn->query("SELECT * from users");
22+
} catch (mysqli_sql_exception $exception) {
23+
echo $exception->getMessage() . PHP_EOL;
24+
}
25+
2126
$info = mysqli_info($conn);
2227

2328
var_dump($info);
@@ -35,9 +40,6 @@ print "done!";
3540
[*] Running query on the fake server...
3641
[*] Received: 140000000353454c454354202a2066726f6d207573657273
3742
[*] Sending - Malicious Tabular Response [Extract heap through buffer over-read]: 0900000100000000000000fa65
38-
39-
Warning: mysqli::query(): RSET_HEADER packet additional data length is past 249 bytes the packet size in %s on line %d
40-
41-
Warning: mysqli::query(): Error reading result set's header in %s on line %d
43+
RSET_HEADER packet additional data length is past the packet size
4244
NULL
4345
done!

ext/mysqlnd/mysqlnd_wireprotocol.c

+3-11
Original file line numberDiff line numberDiff line change
@@ -736,8 +736,7 @@ php_mysqlnd_auth_response_read(MYSQLND_CONN_DATA * conn, void * _packet)
736736
/* p can get past packet size when getting field length so it needs to be checked first
737737
* and after that it can be checked that the net_len is not greater than the packet size */
738738
if ((p - buf) > packet->header.size || packet->header.size - (p - buf) < net_len) {
739-
DBG_ERR_FMT("OK packet message length is past the packet size");
740-
php_error_docref(NULL, E_WARNING, "OK packet message length is past the packet size");
739+
SET_CLIENT_ERROR(error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "OK packet message length is past the packet size");
741740
DBG_RETURN(FAIL);
742741
}
743742
packet->message_len = net_len;
@@ -1121,11 +1120,7 @@ php_mysqlnd_rset_header_read(MYSQLND_CONN_DATA * conn, void * _packet)
11211120
* and after that it can be checked that the len is not greater than the packet size */
11221121
if ((p - buf) > packet->header.size || packet->header.size - (p - buf) < len) {
11231122
size_t local_file_name_over_read = ((p - buf) - packet->header.size) + len;
1124-
DBG_ERR_FMT("RSET_HEADER packet additional data length is past %zu bytes the packet size",
1125-
local_file_name_over_read);
1126-
php_error_docref(NULL, E_WARNING,
1127-
"RSET_HEADER packet additional data length is past %zu bytes the packet size",
1128-
local_file_name_over_read);
1123+
SET_CLIENT_ERROR(error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "RSET_HEADER packet additional data length is past the packet size");
11291124
DBG_RETURN(FAIL);
11301125
}
11311126
packet->info_or_local_file.s = mnd_emalloc(len + 1);
@@ -1278,10 +1273,7 @@ php_mysqlnd_rset_field_read(MYSQLND_CONN_DATA * conn, void * _packet)
12781273
(len = php_mysqlnd_net_field_length(&p)) &&
12791274
len != MYSQLND_NULL_LENGTH)
12801275
{
1281-
DBG_ERR_FMT("Protocol error. Server sent default for unsupported field list");
1282-
php_error_docref(NULL, E_WARNING,
1283-
"Protocol error. Server sent default for unsupported field list (mysqlnd_wireprotocol.c:%u)",
1284-
__LINE__);
1276+
SET_CLIENT_ERROR(error_info, CR_MALFORMED_PACKET, UNKNOWN_SQLSTATE, "Server sent default for unsupported field list");
12851277
DBG_RETURN(FAIL);
12861278
}
12871279

0 commit comments

Comments
 (0)