php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #72413 mysqlnd segfault (fetch_row second parameter typemismatch)
Submitted: 2016-06-15 14:47 UTC Modified: 2020-11-05 15:55 UTC
Votes:1
Avg. Score:5.0 ± 0.0
Reproduced:1 of 1 (100.0%)
Same Version:0 (0.0%)
Same OS:0 (0.0%)
From: martin dot koegler at brz dot gv dot at Assigned: mysql (profile)
Status: Closed Package: *General Issues
PHP Version: 5.6.22 OS: Linux
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: martin dot koegler at brz dot gv dot at
New email:
PHP Version: OS:

 

 [2016-06-15 14:47 UTC] martin dot koegler at brz dot gv dot at
Description:
------------
If the MYSQLI_CURSOR_TYPE_READ_ONLY option is active on a mysqli statement, mysqlnd_fetch_stmt_row_cursor is selected as row fetch method.

mysqlnd_fetch_stmt_row_cursor expects a MYSQLND_STMT passed as "param" parameter.  mysqlnd_res::fetch_into passes a zval as this parameter, which yields to a crash.

Test script:
---------------
<?php
$link1=mysqli_connect(....);
$SQL="SELECT 1";
$stmt=$link1->prepare($SQL);
$stmt->attr_set(MYSQLI_STMT_ATTR_CURSOR_TYPE, MYSQLI_CURSOR_TYPE_READ_ONLY);
$stmt->execute();
$res = $stmt->get_result();
while($res->fetch_row());
?>


Expected result:
----------------
No segfault

Actual result:
--------------
Segfault in
1022                    SET_CLIENT_ERROR(*stmt->conn->error_info, CR_COMMANDS_OUT_OF_SYNC, UNKNOWN_SQLSTATE,

mysqlnd_fetch_stmt_row_cursor at ext/mysqlnd/mysqlnd_ps.c:1022
php_mysqlnd_res_fetch_into_pub at ext/mysqlnd/mysqlnd_result.c:1823

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2016-06-19 13:22 UTC] laruence@php.net
-Status: Open +Status: Verified -Package: mysqlnd_uh +Package: *General Issues -Assigned To: +Assigned To: mysql
 [2017-10-24 05:17 UTC] kalle@php.net
-Status: Verified +Status: Assigned
 [2020-10-29 15:44 UTC] nikic@php.net
Automatic comment on behalf of tekiela246@gmail.com
Revision: http://git.php.net/?p=php-src.git;a=commit;h=b5481defe64c991d0e4307372d69c0ea3cd83378
Log: Fix bug #72413: Segfault with get_result and PS cursors
 [2020-10-29 15:44 UTC] nikic@php.net
-Status: Assigned +Status: Closed
 [2020-11-05 15:55 UTC] girgias@php.net
Related To: Bug #68768
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Tue Mar 19 07:01:29 2024 UTC