Skip to content

Commit

Permalink
Fix bug #72293 - Heap overflow in mysqlnd related to BIT fields
Browse files Browse the repository at this point in the history
  • Loading branch information
smalyshev committed Sep 13, 2016
1 parent 339a865 commit caea2c8
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions ext/mysqlnd/mysqlnd_wireprotocol.c
Original file line number Diff line number Diff line change
Expand Up @@ -1635,6 +1635,7 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
zend_uchar * p = row_buffer->ptr;
size_t data_size = row_buffer->app;
zend_uchar * bit_area = (zend_uchar*) row_buffer->ptr + data_size + 1; /* we allocate from here */
const zend_uchar * const packet_end = (zend_uchar*) row_buffer->ptr + data_size;

DBG_ENTER("php_mysqlnd_rowp_read_text_protocol_aux");

Expand All @@ -1651,6 +1652,10 @@ php_mysqlnd_rowp_read_text_protocol_aux(MYSQLND_MEMORY_POOL_CHUNK * row_buffer,
/* NULL or NOT NULL, this is the question! */
if (len == MYSQLND_NULL_LENGTH) {
ZVAL_NULL(current_field);
} else if ((p + len) > packet_end) {
php_error_docref(NULL, E_WARNING, "Malformed server packet. Field length pointing "MYSQLND_SZ_T_SPEC
" bytes after end of packet", (p + len) - packet_end - 1);
DBG_RETURN(FAIL);
} else {
#if defined(MYSQLND_STRING_TO_INT_CONVERSION)
struct st_mysqlnd_perm_bind perm_bind =
Expand Down

0 comments on commit caea2c8

Please sign in to comment.