andrey                                   Tue, 25 May 2010 22:34:47 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=299758

Log:
Access memory which was really allocated

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
    U   php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c

Modified: php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c	2010-05-25 22:30:05 UTC (rev 299757)
+++ php/php-src/branches/PHP_5_3/ext/mysqlnd/mysqlnd_wireprotocol.c	2010-05-25 22:34:47 UTC (rev 299758)
@@ -1908,8 +1908,10 @@
 {
 	struct st_mysqlnd_packet_greet * packet = mnd_pecalloc(1, packet_methods[PROT_GREET_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_greet_packet");
-	packet->header.m = &packet_methods[PROT_GREET_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_GREET_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1921,8 +1923,10 @@
 {
 	struct st_mysqlnd_packet_auth * packet = mnd_pecalloc(1, packet_methods[PROT_AUTH_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_auth_packet");
-	packet->header.m = &packet_methods[PROT_AUTH_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_AUTH_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1934,8 +1938,10 @@
 {
 	struct st_mysqlnd_packet_ok * packet = mnd_pecalloc(1, packet_methods[PROT_OK_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_ok_packet");
-	packet->header.m = &packet_methods[PROT_OK_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_OK_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1947,8 +1953,10 @@
 {
 	struct st_mysqlnd_packet_eof * packet = mnd_pecalloc(1, packet_methods[PROT_EOF_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_eof_packet");
-	packet->header.m = &packet_methods[PROT_EOF_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_EOF_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1960,8 +1968,10 @@
 {
 	struct st_mysqlnd_packet_command * packet = mnd_pecalloc(1, packet_methods[PROT_CMD_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_command_packet");
-	packet->header.m = &packet_methods[PROT_CMD_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_CMD_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1973,8 +1983,10 @@
 {
 	struct st_mysqlnd_packet_rset_header * packet = mnd_pecalloc(1, packet_methods[PROT_RSET_HEADER_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_rset_header_packet");
-	packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1986,8 +1998,10 @@
 {
 	struct st_mysqlnd_packet_res_field * packet = mnd_pecalloc(1, packet_methods[PROT_RSET_FLD_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_result_field_packet");
-	packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1999,8 +2013,10 @@
 {
 	struct st_mysqlnd_packet_row * packet = mnd_pecalloc(1, packet_methods[PROT_ROW_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_row_packet");
-	packet->header.m = &packet_methods[PROT_ROW_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_ROW_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2012,8 +2028,10 @@
 {
 	struct st_mysqlnd_packet_stats * packet = mnd_pecalloc(1, packet_methods[PROT_STATS_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_stats_packet");
-	packet->header.m = &packet_methods[PROT_STATS_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_STATS_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2025,8 +2043,10 @@
 {
 	struct st_mysqlnd_packet_prepare_response * packet = mnd_pecalloc(1, packet_methods[PROT_PREPARE_RESP_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_prepare_response_packet");
-	packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2038,8 +2058,10 @@
 {
 	struct st_mysqlnd_packet_chg_user_resp * packet = mnd_pecalloc(1, packet_methods[PROT_CHG_USER_RESP_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_change_user_response_packet");
-	packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2070,10 +2092,11 @@

 	DBG_ENTER("mysqlnd_protocol_init");
 	DBG_INF_FMT("persistent=%d", persistent);
-	ret->persistent = persistent;
+	if (ret) {
+		ret->persistent = persistent;
+		ret->m = mysqlnd_mysqlnd_protocol_methods;
+	}

-	ret->m = mysqlnd_mysqlnd_protocol_methods;
-
 	DBG_RETURN(ret);
 }
 /* }}} */

Modified: php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c
===================================================================
--- php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c	2010-05-25 22:30:05 UTC (rev 299757)
+++ php/php-src/trunk/ext/mysqlnd/mysqlnd_wireprotocol.c	2010-05-25 22:34:47 UTC (rev 299758)
@@ -1908,8 +1908,10 @@
 {
 	struct st_mysqlnd_packet_greet * packet = mnd_pecalloc(1, packet_methods[PROT_GREET_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_greet_packet");
-	packet->header.m = &packet_methods[PROT_GREET_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_GREET_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1921,8 +1923,10 @@
 {
 	struct st_mysqlnd_packet_auth * packet = mnd_pecalloc(1, packet_methods[PROT_AUTH_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_auth_packet");
-	packet->header.m = &packet_methods[PROT_AUTH_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_AUTH_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1934,8 +1938,10 @@
 {
 	struct st_mysqlnd_packet_ok * packet = mnd_pecalloc(1, packet_methods[PROT_OK_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_ok_packet");
-	packet->header.m = &packet_methods[PROT_OK_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_OK_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1947,8 +1953,10 @@
 {
 	struct st_mysqlnd_packet_eof * packet = mnd_pecalloc(1, packet_methods[PROT_EOF_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_eof_packet");
-	packet->header.m = &packet_methods[PROT_EOF_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_EOF_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1960,8 +1968,10 @@
 {
 	struct st_mysqlnd_packet_command * packet = mnd_pecalloc(1, packet_methods[PROT_CMD_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_command_packet");
-	packet->header.m = &packet_methods[PROT_CMD_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_CMD_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1973,8 +1983,10 @@
 {
 	struct st_mysqlnd_packet_rset_header * packet = mnd_pecalloc(1, packet_methods[PROT_RSET_HEADER_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_rset_header_packet");
-	packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_RSET_HEADER_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1986,8 +1998,10 @@
 {
 	struct st_mysqlnd_packet_res_field * packet = mnd_pecalloc(1, packet_methods[PROT_RSET_FLD_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_result_field_packet");
-	packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_RSET_FLD_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -1999,8 +2013,10 @@
 {
 	struct st_mysqlnd_packet_row * packet = mnd_pecalloc(1, packet_methods[PROT_ROW_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_row_packet");
-	packet->header.m = &packet_methods[PROT_ROW_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_ROW_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2012,8 +2028,10 @@
 {
 	struct st_mysqlnd_packet_stats * packet = mnd_pecalloc(1, packet_methods[PROT_STATS_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_stats_packet");
-	packet->header.m = &packet_methods[PROT_STATS_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_STATS_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2025,8 +2043,10 @@
 {
 	struct st_mysqlnd_packet_prepare_response * packet = mnd_pecalloc(1, packet_methods[PROT_PREPARE_RESP_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_prepare_response_packet");
-	packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_PREPARE_RESP_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2038,8 +2058,10 @@
 {
 	struct st_mysqlnd_packet_chg_user_resp * packet = mnd_pecalloc(1, packet_methods[PROT_CHG_USER_RESP_PACKET].struct_size, persistent);
 	DBG_ENTER("mysqlnd_protocol::get_change_user_response_packet");
-	packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
-	packet->header.persistent = persistent;
+	if (packet) {
+		packet->header.m = &packet_methods[PROT_CHG_USER_RESP_PACKET];
+		packet->header.persistent = persistent;
+	}
 	DBG_RETURN(packet);
 }
 /* }}} */
@@ -2070,10 +2092,11 @@

 	DBG_ENTER("mysqlnd_protocol_init");
 	DBG_INF_FMT("persistent=%d", persistent);
-	ret->persistent = persistent;
+	if (ret) {
+		ret->persistent = persistent;
+		ret->m = mysqlnd_mysqlnd_protocol_methods;
+	}

-	ret->m = mysqlnd_mysqlnd_protocol_methods;
-
 	DBG_RETURN(ret);
 }
 /* }}} */
-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to