From 7563b6ea6606e92fa76e8d2f6d965042c584b5e7 Mon Sep 17 00:00:00 2001 From: Konstantin Shulgin <konstantin.shulgin@gmail.com> Date: Wed, 30 May 2012 16:24:11 +0400 Subject: [PATCH] bug899343: review fixes. --- include/iproto.h | 4 ++-- src/iproto.m | 9 ++++++--- test/box/iproto.result | 13 +++---------- test/box/iproto.test | 2 +- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/include/iproto.h b/include/iproto.h index f341876de6..9bd569c965 100644 --- a/include/iproto.h +++ b/include/iproto.h @@ -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, }; /* diff --git a/src/iproto.m b/src/iproto.m index ca253b04e7..f5d1c19e33 100644 --- a/src/iproto.m +++ b/src/iproto.m @@ -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); } diff --git a/test/box/iproto.result b/test/box/iproto.result index 08e029a124..5661ba192e 100644 --- a/test/box/iproto.result +++ b/test/box/iproto.result @@ -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 +--- diff --git a/test/box/iproto.test b/test/box/iproto.test index d21def95d3..2b294a38c9 100644 --- a/test/box/iproto.test +++ b/test/box/iproto.test @@ -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() -- GitLab