Disconnect instead of crashing if a client sends a large Connect
We were rejecting connections if the sha256 didn't match, but generally
when the sha256 doesn't match, someone has changed the size of the
Connect message. This was resulting in the Read call overflowing the
buffer and CHECKing. Instead, trigger an abort in this case, and boot
the client safely.
Change-Id: I565acc61e14c99b3e32fd50bea9972cd195bb28d
Signed-off-by: James Kuszmaul <james.kuszmaul@bluerivertech.com>
diff --git a/aos/network/sctp_lib.h b/aos/network/sctp_lib.h
index 42cecea..14509e4 100644
--- a/aos/network/sctp_lib.h
+++ b/aos/network/sctp_lib.h
@@ -53,7 +53,14 @@
struct sockaddr_storage sin;
// Data type. Is it a block of data, or is it a struct sctp_notification?
- enum MessageType { kMessage, kNotification } message_type;
+ enum MessageType {
+ // Block of data?
+ kMessage,
+ // struct sctp_notification?
+ kNotification,
+ // Client sent too large a message and was disconnected.
+ kOverflow,
+ } message_type;
size_t size = 0u;
uint8_t *mutable_data() {