php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Return to Bug #71863
Patch fix-mysqlnd-result-set-segfaul revision 2016-04-11 14:31 UTC by reyad dot attiyat at gmail dot com

Patch fix-mysqlnd-result-set-segfaul for MySQLi related Bug #71863

Patch version 2016-04-11 14:31 UTC

Return to Bug #71863 | Download this patch
Patch Revisions:

Developer: reyad.attiyat@gmail.com

From 774e2638e2f8e3b4c7c11d9a047af23bef59ca0d Mon Sep 17 00:00:00 2001
From: Reyad Attiyat <reyad.attiyat@gmail.com>
Date: Mon, 11 Apr 2016 14:23:32 +0000
Subject: [PATCH] Fix segfault on mysqlnd result set error

This patch fixes bug# 71863 which caused a segfault when the result set
contained an error. This occurs becuase the buffered result set does
not contain callbacks in its mysqlnd error_info struct and would fail
on a null pointer when called with the macro COPY_CLIENT_ERROR.

The fix simply copies the error info struct from the row_packet into
the buffered result set, as was done before.
---
 ext/mysqlnd/mysqlnd_result.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/ext/mysqlnd/mysqlnd_result.c b/ext/mysqlnd/mysqlnd_result.c
index c4aa537..4f8d3e8 100644
--- a/ext/mysqlnd/mysqlnd_result.c
+++ b/ext/mysqlnd/mysqlnd_result.c
@@ -1391,7 +1391,7 @@ MYSQLND_METHOD(mysqlnd_res, store_result_fetch_data)(MYSQLND_CONN_DATA * const c
 	}
 
 	if (ret == FAIL) {
-		COPY_CLIENT_ERROR(&set->error_info, row_packet->error_info);
+		memcpy(&set->error_info, &row_packet->error_info, sizeof(MYSQLND_ERROR_INFO));
 	} else {
 		/* libmysql's documentation says it should be so for SELECT statements */
 		UPSERT_STATUS_SET_AFFECTED_ROWS(conn->upsert_status, set->row_count);
-- 
2.1.4

 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Apr 25 16:01:28 2024 UTC