Commit Graph

243 Commits

Author SHA1 Message Date
Andrey Hristov
a4ad111454 fix two more warnings 2010-10-04 14:52:14 +00:00
Andrey Hristov
026da7d4a0 fix two more warnings 2010-10-04 14:52:14 +00:00
Andrey Hristov
216effe4f5 WS fixes 2010-09-23 16:03:22 +00:00
Andrey Hristov
859a1404bf WS fixes 2010-09-23 16:03:22 +00:00
Andrey Hristov
9da177f8d5 Allocate memory in a burst mode, and later use it. Increases
locality of the data.
Also use MYSQLND_INC_CONN_STATISTIC in one place, instead of
two, thus removing code duplication from macro expansion - less
code to fit in the instruction cache.
2010-08-12 13:23:16 +00:00
Andrey Hristov
6fc06f265e Allocate memory in a burst mode, and later use it. Increases
locality of the data.
Also use MYSQLND_INC_CONN_STATISTIC in one place, instead of
two, thus removing code duplication from macro expansion - less
code to fit in the instruction cache.
2010-08-12 13:23:16 +00:00
Andrey Hristov
c974313aed Switch from using PHP_MAJOR_VERSION to separate define for
unicode. Unicode is no more, but these are "bookmarks" where
to change mysqlnd, if Unicode becomes trendy again.
2010-08-12 12:02:02 +00:00
Andrey Hristov
92ef63a07b Switch from using PHP_MAJOR_VERSION to separate define for
unicode. Unicode is no more, but these are "bookmarks" where
to change mysqlnd, if Unicode becomes trendy again.
2010-08-12 12:02:02 +00:00
Andrey Hristov
53324e8830 Fix sprintf modifiers all around the place. In most cases
%u should be used. Where size_t is used then MYSQLND_SZ_T_SPEC should be
the modifier
2010-06-21 15:32:26 +00:00
Andrey Hristov
baf72b7336 Fix sprintf modifiers all around the place. In most cases
%u should be used. Where size_t is used then MYSQLND_SZ_T_SPEC should be
the modifier
2010-06-21 15:32:26 +00:00
Andrey Hristov
698539fa79 fix valgrind warnings on 64bit, thread_is is strictly 32bit 2010-06-21 14:49:45 +00:00
Andrey Hristov
523960892c fix valgrind warnings on 64bit, thread_is is strictly 32bit 2010-06-21 14:49:45 +00:00
Andrey Hristov
7f79e86886 fix type mismatch, this is fresh misunderstanding 2010-06-18 11:56:25 +00:00
Andrey Hristov
d3d7447803 fix type mismatch, this is fresh misunderstanding 2010-06-18 11:56:25 +00:00
Andrey Hristov
59205a6655 split mysqlnd_connect() in two parts, one doing the authorization 2010-06-17 11:37:49 +00:00
Andrey Hristov
ae4ae5a313 split mysqlnd_connect() in two parts, one doing the authorization 2010-06-17 11:37:49 +00:00
Andrey Hristov
047d6f2855 Handle problems in the row_decoder, return type used to be void,
now it can return on problems.
2010-05-31 17:57:03 +00:00
Andrey Hristov
d02e785d68 Handle problems in the row_decoder, return type used to be void,
now it can return on problems.
2010-05-31 17:57:03 +00:00
Ulf Wendel
c0a8ce2f61 Updating test to reflect the latest and more verbose mysqlnd error messages, updating mysqlnd error message as well. 2010-05-31 13:56:42 +00:00
Ulf Wendel
73a32c52d2 Updating test to reflect the latest and more verbose mysqlnd error messages, updating mysqlnd error message as well. 2010-05-31 13:56:42 +00:00
Andrey Hristov
4abc7a1e69 Access memory which was really allocated 2010-05-25 22:34:47 +00:00
Andrey Hristov
decdfeeeb2 Access memory which was really allocated 2010-05-25 22:34:47 +00:00
Andrey Hristov
34ffc8a6c4 Export MYSQLND_PROTOCOL methods 2010-05-14 13:32:27 +00:00
Andrey Hristov
faf4659295 Export MYSQLND_PROTOCOL methods 2010-05-14 13:32:27 +00:00
Andrey Hristov
ce0ea97850 OOM fixes 2010-05-14 13:04:33 +00:00
Andrey Hristov
dd85f9c2f2 OOM fixes 2010-05-14 13:04:33 +00:00
Andrey Hristov
ebae62d7c4 OOM stability fixes 2010-05-04 14:02:42 +00:00
Andrey Hristov
d53337bbe7 OOM stability fixes 2010-05-04 14:02:42 +00:00
Andrey Hristov
c32bae720c Handle OOM in block_alloc_get_chunk, and also in the caller
in mysqlnd_wireprotocol.c
2010-05-03 16:20:46 +00:00
Andrey Hristov
f9fe805abe Handle OOM in block_alloc_get_chunk, and also in the caller
in mysqlnd_wireprotocol.c
2010-05-03 16:20:46 +00:00
Andrey Hristov
ec0fe858c6 Remove unused parameter 2010-05-03 16:09:05 +00:00
Andrey Hristov
864f2da733 Remove unused parameter 2010-05-03 16:09:05 +00:00
Andrey Hristov
8e8348a4b0 Handle OOM when resizing blocks during data fetch 2010-05-03 14:16:04 +00:00
Andrey Hristov
de4a5156e6 Handle OOM when resizing blocks during data fetch 2010-05-03 14:16:04 +00:00
Andrey Hristov
9b468d9577 Fix crash if OOM and USE_ZEND_ALLOC=0 2010-04-29 11:49:08 +00:00
Andrey Hristov
6c1a2831f6 Fix crash if OOM and USE_ZEND_ALLOC=0 2010-04-29 11:49:08 +00:00
Andrey Hristov
ad4b429633 Fixed few buffer overflows reported by Stefan Esser. 2010-04-28 15:35:52 +00:00
Andrey Hristov
6d88d1a75e Fixed few buffer overflows reported by Stefan Esser. 2010-04-28 15:35:52 +00:00
Andrey Hristov
1838fcc7b0 const-ify fields 2010-04-28 12:29:13 +00:00
Andrey Hristov
16d5d5966e const-ify fields 2010-04-28 12:29:13 +00:00
Andrey Hristov
691522780f Hardening the reads of mysqlnd.
All packets but the row data packet are read into preallocated buffer,
either on the stack or on the heap (cmd_buffer). The size of the buffer
is always checked to skip buffer overruns. Only up to the size of the
buffer is stored into the buffer but packet->header.size has the size of
all data sent. In this case network layer bails.

This patch hardenes the reads, so if packets are malformed and shorter
than they should be there will be no further reads in the buffer.
In short, detection of malformed packets.
2010-04-20 20:02:32 +00:00
Andrey Hristov
6dec27d58b Hardening the reads of mysqlnd.
All packets but the row data packet are read into preallocated buffer,
either on the stack or on the heap (cmd_buffer). The size of the buffer
is always checked to skip buffer overruns. Only up to the size of the
buffer is stored into the buffer but packet->header.size has the size of
all data sent. In this case network layer bails.

This patch hardenes the reads, so if packets are malformed and shorter
than they should be there will be no further reads in the buffer.
In short, detection of malformed packets.
2010-04-20 20:02:32 +00:00
Andrey Hristov
efa0077e08 put the trigger in the right place 2010-04-20 19:09:56 +00:00
Andrey Hristov
f2d23c7f37 put the trigger in the right place 2010-04-20 19:09:56 +00:00
Andrey Hristov
804b950562 It is possible that change user tries an user who has old password.
Instead of error message that doesn't say much there is more information now.
2010-04-20 18:04:24 +00:00
Andrey Hristov
eda9959e36 It is possible that change user tries an user who has old password.
Instead of error message that doesn't say much there is more information now.
2010-04-20 18:04:24 +00:00
Felipe Pena
a175419f84 - Fix copyrights 2010-04-20 13:50:34 +00:00
Felipe Pena
6d951e2ded - Fix copyrights 2010-04-20 13:50:34 +00:00
Andrey Hristov
664b2389ca Last batch of int/uint comparison fixes 2010-04-15 15:58:26 +00:00
Andrey Hristov
fb76a3f2db Last batch of int/uint comparison fixes 2010-04-15 15:58:26 +00:00
Andrey Hristov
76d64590b0 More int/uint comparison warning fixes 2010-04-15 15:53:58 +00:00
Andrey Hristov
7f43fc3b02 More int/uint comparison warning fixes 2010-04-15 15:53:58 +00:00
Andrey Hristov
6aa682f564 CS + WS changes 2010-04-15 12:55:04 +00:00
Andrey Hristov
a9880e78c6 CS + WS changes 2010-04-15 12:55:04 +00:00
Andrey Hristov
dd9fc198ce Fix for bug#49234 method not found ssl_set
Patch was tested and compiles on Windows. (Thanks Kalle)
2010-04-15 11:01:30 +00:00
Andrey Hristov
c04f752625 Fix for bug#49234 method not found ssl_set
Patch was tested and compiles on Windows. (Thanks Kalle)
2010-04-15 11:01:30 +00:00
Andrey Hristov
3bd2faff8c Fixint INT_AND_FLOAT_AS native. It was working ok on 64bit but
because on 32bit SIZEOF_LONG is 4 and INT64 from MySQL is 8 everything
was converted to string, even if it was able to put it in a long.
This closes Request #50651 Native type cast returns wrong result
2010-04-08 13:20:37 +00:00
Andrey Hristov
c0531d8db0 Fixint INT_AND_FLOAT_AS native. It was working ok on 64bit but
because on 32bit SIZEOF_LONG is 4 and INT64 from MySQL is 8 everything
was converted to string, even if it was able to put it in a long.
This closes Request #50651 Native type cast returns wrong result
2010-04-08 13:20:37 +00:00
Andrey Hristov
aa8f43fad9 Recommit with an Windows build fix:
Fix inconsistencies
- memory allocated with spprintf, or likes, outside of mysqlnd's
allocator functions should not be freed by the mysqlnd's allocator
(a wrapper around emalloc/malloc).
- memory allocated by the mysqlnd's allocator should only be freed
  by it.
- add a mode to track memory usage (malloc/free)
2010-04-06 13:28:23 +00:00
Pierre Joye
96e2651fa2 - revert revision 297277, break the builds (declaration must go 1st, size of void * and other known situations). Also Johannes, can you check that commit pls? Thought we were in bugs fixing only for 5.3 2010-04-01 20:21:50 +00:00
Andrey Hristov
d339672e45 Fix inconsistencies
- memory allocated with spprintf, or likes, outside of mysqlnd's
allocator functions should not be freed by the mysqlnd's allocator
(a wrapper around emalloc/malloc).
- memory allocated by the mysqlnd's allocator should only be freed
  by it.
- add a mode to track memory usage (malloc/free)
2010-04-01 13:26:41 +00:00
Andrey Hristov
f534df710e Fix inconsistencies
- memory allocated with spprintf, or likes, outside of mysqlnd's
allocator functions should not be freed by the mysqlnd's allocator
(a wrapper around emalloc/malloc).
- memory allocated by the mysqlnd's allocator should only be freed
  by it.
- add a mode to track memory usage (malloc/free)
2010-04-01 13:26:41 +00:00
Andrey Hristov
94cd357f5b Make it coupled - what is allocated with mnd_ should be freed
with mnd_ and vice versa.
Added mnd_pestrndup and mnd_pestrdup, which wrap the normal
calls to be able to track this calls.
Fixed some failing tests.
2010-03-29 17:04:16 +00:00
Andrey Hristov
4870cac70e Make it coupled - what is allocated with mnd_ should be freed
with mnd_ and vice versa.
Added mnd_pestrndup and mnd_pestrdup, which wrap the normal
calls to be able to track this calls.
Fixed some failing tests.
2010-03-29 17:04:16 +00:00
Andrey Hristov
ec36ac1610 Fix tests that fail when the MySQL's socket file is not /tmp/mysql.sock
as it is in when compiled from source and the default for mysqlnd.
SuSE for example uses /var/run/mysql/mysql.sock . Also, sql.safe_mode
(ext/mysql and ingres) needs the socket.
Fix possible crashes in mysqlnd. When packets are shorter, functions should
return error.
2010-03-26 16:58:25 +00:00
Andrey Hristov
7868bca437 Fix tests that fail when the MySQL's socket file is not /tmp/mysql.sock
as it is in when compiled from source and the default for mysqlnd.
SuSE for example uses /var/run/mysql/mysql.sock . Also, sql.safe_mode
(ext/mysql and ingres) needs the socket.
Fix possible crashes in mysqlnd. When packets are shorter, functions should
return error.
2010-03-26 16:58:25 +00:00
Andrey Hristov
ccfd9cd744 allow persistency of PS 2010-03-12 13:03:46 +00:00
Andrey Hristov
564a1d07f8 allow persistency of PS 2010-03-12 13:03:46 +00:00
Andrey Hristov
0e71a58662 Fix second bug in that code, + instead of += thus not increasing
a pointer and mangling data. Again, ext/mysql and ext/mysqli doesn't
have access to this codepath.
2010-02-01 17:12:40 +00:00
Andrey Hristov
7b68aab24c Fix second bug in that code, + instead of += thus not increasing
a pointer and mangling data. Again, ext/mysql and ext/mysqli doesn't
have access to this codepath.
2010-02-01 17:12:40 +00:00
Andrey Hristov
228b68bbab Fix a bug in mysqlnd where a pointer was not incremented
and thus wrong data was saved MYSQLND_FIELD::db. However, this
wasn't caught because there is no code in mysql/mysqli/pdo_mysql
which reads that field of the structure. The problem was found
during code review.
2010-02-01 16:12:03 +00:00
Andrey Hristov
befab3e8c3 Fix a bug in mysqlnd where a pointer was not incremented
and thus wrong data was saved MYSQLND_FIELD::db. However, this
wasn't caught because there is no code in mysql/mysqli/pdo_mysql
which reads that field of the structure. The problem was found
during code review.
2010-02-01 16:12:03 +00:00
Andrey Hristov
176e6dd2f2 make mysqlnd's tracing API more reusable 2010-01-13 14:06:02 +00:00
Andrey Hristov
7ff1184be2 make mysqlnd's tracing API more reusable 2010-01-13 14:06:02 +00:00
Andrey Hristov
68cd1b8e86 more typedef cosmetics 2010-01-11 20:18:56 +00:00
Andrey Hristov
dc09fa81f5 more typedef cosmetics 2010-01-11 20:18:56 +00:00
Andrey Hristov
a449a371a8 cosmetics. typedef-ed types should be in capital case 2010-01-11 20:10:10 +00:00
Andrey Hristov
2331e28509 cosmetics. typedef-ed types should be in capital case 2010-01-11 20:10:10 +00:00
Andrey Hristov
9939429f4e remove extern defintion of a variable that is no more
used outside of the file where it is declared.
Also really export with PHPAPI the protocol init/deinit functions
2010-01-11 19:13:43 +00:00
Andrey Hristov
1a108f1bae remove extern defintion of a variable that is no more
used outside of the file where it is declared.
Also really export with PHPAPI the protocol init/deinit functions
2010-01-11 19:13:43 +00:00
Andrey Hristov
d20fdd603b improve the stats subsystem. Reduce the number of macro definitions
in half by smartly introducing 2 new macros. Make MYSQLND::stats a pointer
from being aggregated and add triggers.
2010-01-08 17:35:20 +00:00
Andrey Hristov
a98a67940a improve the stats subsystem. Reduce the number of macro definitions
in half by smartly introducing 2 new macros. Make MYSQLND::stats a pointer
from being aggregated and add triggers.
2010-01-08 17:35:20 +00:00
Andrey Hristov
3264e51983 add restart_psession and end_psession hooks 2010-01-08 13:47:03 +00:00
Andrey Hristov
fcef58951b add restart_psession and end_psession hooks 2010-01-08 13:47:03 +00:00
Andrey Hristov
81b0630f5a Change of way the packet objects are created/initialised
If the protocol gets changed, ever, we can decide at runtime
easily which protocol to use by instantiating the right protocol
object. But this is restricted to the structure of the packets, not
the flow.
2010-01-07 19:44:59 +00:00
Andrey Hristov
73b23fca37 Change of way the packet objects are created/initialised
If the protocol gets changed, ever, we can decide at runtime
easily which protocol to use by instantiating the right protocol
object. But this is restricted to the structure of the packets, not
the flow.
2010-01-07 19:44:59 +00:00
Andrey Hristov
a3e5d1852a Move this function to MYSQLND_NET as it works on the
php stream
2009-12-21 16:52:10 +00:00
Andrey Hristov
41ac91aecf Move this function to MYSQLND_NET as it works on the
php stream
2009-12-21 16:52:10 +00:00
Andrey Hristov
3e3d0e0d88 magic numbers to macros 2009-12-21 16:17:31 +00:00
Andrey Hristov
ce349e3540 magic numbers to macros 2009-12-21 16:17:31 +00:00
Andrey Hristov
f8dcfbc74f refactoring : move more network related functions to
mysqlnd_net.c . Now communication is split on two levels:
- logical (functions send and receive)
- physical (functions network_read and network_write)
2009-12-17 13:29:46 +00:00
Andrey Hristov
028bd4ba02 refactoring : move more network related functions to
mysqlnd_net.c . Now communication is split on two levels:
- logical (functions send and receive)
- physical (functions network_read and network_write)
2009-12-17 13:29:46 +00:00
Andrey Hristov
60697e1876 During refactoring of the function mysqlnd_stream_write_w_header() it was
found that there is a bug in the way the data is sent, although a very rare
one which will only affect very large queries which have length 16777214. The
communication will hang. A way to test it is to execute the following:
./php -r '$c=mysqli_connect("127.0.0.1","root","root","test");
$q="insert into test.tblob values(\"".str_repeat("a",256*256*256-1-34)."\")";
$c->query($q);'
2009-12-17 12:30:58 +00:00
Andrey Hristov
22528b14a4 During refactoring of the function mysqlnd_stream_write_w_header() it was
found that there is a bug in the way the data is sent, although a very rare
one which will only affect very large queries which have length 16777214. The
communication will hang. A way to test it is to execute the following:
./php -r '$c=mysqli_connect("127.0.0.1","root","root","test");
$q="insert into test.tblob values(\"".str_repeat("a",256*256*256-1-34)."\")";
$c->query($q);'
2009-12-17 12:30:58 +00:00
Andrey Hristov
a1ef2d9fb3 Remove unneeded dereferences
(oops, committed the trunk changes from a wrong directory, which splitted
this commit).
2009-12-16 14:06:09 +00:00
Andrey Hristov
6adc50b460 Remove unneeded dereferences 2009-12-16 14:05:35 +00:00
Andrey Hristov
b3546d1b5e move MYSQLND_NET code to a separate file.
mysqlnd_wireprotocol is about the protocol not the transport
layer
2009-12-16 12:59:38 +00:00
Andrey Hristov
9f21c91a08 move MYSQLND_NET code to a separate file.
mysqlnd_wireprotocol is about the protocol not the transport
layer
2009-12-16 12:59:38 +00:00
Andrey Hristov
c101f7f542 Move code out of mysqlnd_conn::connect to mysqlnd_net::connect.
Thus mysqlnd_conn::connect() does less of what it should not do - think
about the transport level.
2009-12-15 17:33:06 +00:00
Andrey Hristov
1fc65ed8bb Move code out of mysqlnd_conn::connect to mysqlnd_net::connect.
Thus mysqlnd_conn::connect() does less of what it should not do - think
about the transport level.
2009-12-15 17:33:06 +00:00