summaryrefslogtreecommitdiff
path: root/sql/net_serv.cc
diff options
context:
space:
mode:
authorunknown <Sinisa@sinisa.nasamreza.org>2003-01-04 21:02:58 +0200
committerunknown <Sinisa@sinisa.nasamreza.org>2003-01-04 21:02:58 +0200
commitb2c904ec671fe5425623025682b9b54786365845 (patch)
treea1256a9174e4ea3ddf6bc05f527673dc9c0c70e6 /sql/net_serv.cc
parent4c239771855b5f1866d20ade00d94f44b9233d91 (diff)
downloadmariadb-git-b2c904ec671fe5425623025682b9b54786365845.tar.gz
Fixing that 3.23 API / clients do not disconnect if a large
packet is issued. BitKeeper/deleted/.del-net.c~ef21d6402bb882f9: Delete: libmysql/net.c sql/sql_select.cc: reversing a fix, but we shall yet see about this one ...
Diffstat (limited to 'sql/net_serv.cc')
-rw-r--r--sql/net_serv.cc22
1 files changed, 19 insertions, 3 deletions
diff --git a/sql/net_serv.cc b/sql/net_serv.cc
index 2583f0767f4..c6a0b8c5b3e 100644
--- a/sql/net_serv.cc
+++ b/sql/net_serv.cc
@@ -34,13 +34,18 @@
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
+#ifdef MYSQL_SERVER
+#include <violite.h>
+#endif
+
+#define MAX_PACKET_LENGTH (256L*256L*256L-1)
#ifdef MYSQL_SERVER
ulong max_allowed_packet=65536;
extern ulong net_read_timeout,net_write_timeout;
extern uint test_flags;
#else
-ulong max_allowed_packet=16*1024*1024L-1;
+ulong max_allowed_packet=MAX_PACKET_LENGTH;
ulong net_read_timeout= NET_READ_TIMEOUT;
ulong net_write_timeout= NET_WRITE_TIMEOUT;
#endif
@@ -226,6 +231,12 @@ int
my_net_write(NET *net,const char *packet,ulong len)
{
uchar buff[NET_HEADER_SIZE];
+ if (len >= MAX_PACKET_LENGTH)
+ {
+ net->error=1;
+ net->last_errno=ER_NET_PACKET_TOO_LARGE;
+ return 1;
+ }
int3store(buff,len);
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
if (net_write_buff(net,(char*) buff,NET_HEADER_SIZE))
@@ -238,7 +249,12 @@ net_write_command(NET *net,uchar command,const char *packet,ulong len)
{
uchar buff[NET_HEADER_SIZE+1];
uint length=len+1; /* 1 extra byte for command */
-
+ if (length >= MAX_PACKET_LENGTH)
+ {
+ net->error=1;
+ net->last_errno=ER_NET_PACKET_TOO_LARGE;
+ return 1;
+ }
int3store(buff,length);
buff[3]= (net->compress) ? 0 : (uchar) (net->pkt_nr++);
buff[4]=command;
@@ -276,7 +292,7 @@ net_real_write(NET *net,const char *packet,ulong len)
int length;
char *pos,*end;
thr_alarm_t alarmed;
-#if !defined(__WIN__)
+#if !defined(__WIN__) && !defined(__EMX__) && !defined(OS2)
ALARM alarm_buff;
#endif
uint retry_count=0;