Skip to content

Commit

Permalink
bug899343: review fixes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Konstantin Shulgin committed May 30, 2012
1 parent 0d3e60b commit 7563b6e
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 16 deletions.
4 changes: 2 additions & 2 deletions include/iproto.h
Expand Up @@ -28,8 +28,8 @@
#include <tbuf.h> /* for struct tbuf */

enum {
/** Maximal iproto package length (2GiB) */
IPROTO_LEN_MAX = 2147483648,
/** Maximal iproto package body length (2GiB) */
IPROTO_BODY_LEN_MAX = 2147483648,
};

/*
Expand Down
9 changes: 6 additions & 3 deletions src/iproto.m
Expand Up @@ -132,9 +132,12 @@ static void iproto_reply(iproto_callback callback, struct tbuf *request)
static void
iproto_validate_header(struct iproto_header *header)
{
if (header->len > IPROTO_LEN_MAX) {
/* the package has invalid length, close connection */
say_error("Invalid iproto package length: %llu",
if (header->len > IPROTO_BODY_LEN_MAX) {
/*
* The package is too big, just close connection for now to
* avoid DoS.
*/
say_error("received package is too big: %llu",
(unsigned long long)header->len);
tnt_raise(FiberCancelException);
}
Expand Down
13 changes: 3 additions & 10 deletions test/box/iproto.result
Expand Up @@ -9,13 +9,6 @@
# sending the package with invalid length
12
# checking what is server alive
show stat
---
statistics:
REPLACE: { rps: 0 , total: 0 }
SELECT: { rps: 0 , total: 0 }
UPDATE: { rps: 0 , total: 0 }
DELETE_1_3: { rps: 0 , total: 0 }
DELETE: { rps: 0 , total: 0 }
CALL: { rps: 0 , total: 0 }
...
ping
ok
---
2 changes: 1 addition & 1 deletion test/box/iproto.test
Expand Up @@ -21,7 +21,7 @@ print "# sending the package with invalid length"
inval_request = struct.pack('<LLL', 17, 4294967290, 1)
print s.send(inval_request)
print "# checking what is server alive"
exec admin "show stat"
exec sql "ping"

# closing connection
s.close()

0 comments on commit 7563b6e

Please sign in to comment.