additional peer exceptions added

added a few cases where we should be raising peer exceptions when
delivered invalid frames from the server (per spec)
This commit is contained in:
Matt Broadstone 2014-06-19 13:36:11 -04:00
parent 81f9437495
commit cb52911bed
2 changed files with 35 additions and 20 deletions

View File

@ -170,9 +170,7 @@ void ClientPrivate::_q_readyRead()
const quint8 type = *(quint8*)&bufferData[0];
const quint8 magic = *(quint8*)&bufferData[Frame::HEADER_SIZE + payloadSize];
if (magic != Frame::FRAME_END) {
qAmqpDebug() << Q_FUNC_INFO << "FATAL: wrong end of frame";
buffer.clear();
socket->close();
close(UnexpectedFrameError, "wrong end of frame");
return;
}
@ -200,6 +198,9 @@ void ClientPrivate::_q_readyRead()
if (frame.size() > frameMax) {
close(FrameError, "frame size too large");
return;
} else if (frame.channel() <= 0) {
close(ChannelError, "channel number must be greater than zero");
return;
}
foreach (Frame::ContentHandler *methodHandler, contentHandlerByChannel[frame.channel()])
@ -212,6 +213,9 @@ void ClientPrivate::_q_readyRead()
if (frame.size() > frameMax) {
close(FrameError, "frame size too large");
return;
} else if (frame.channel() <= 0) {
close(ChannelError, "channel number must be greater than zero");
return;
}
foreach (Frame::ContentBodyHandler *methodHandler, bodyHandlersByChannel[frame.channel()])
@ -219,10 +223,20 @@ void ClientPrivate::_q_readyRead()
}
break;
case Frame::ftHeartbeat:
{
Frame::Method frame(streamB);
if (frame.channel() != 0) {
close(FrameError, "heartbeat must have channel id zero");
return;
}
qAmqpDebug("AMQP: Heartbeat");
}
break;
default:
qAmqpDebug() << "AMQP: Unknown frame type: " << type;
close(FrameError, "invalid frame type");
return;
}
} else {
break;

View File

@ -82,7 +82,8 @@ namespace Frame
/*
* @brief Definition implementation of TableField type
* @detailed Define implementation TableField type in builtin Qt types. Key contains field name, value contains field data.
* @detailed Define implementation TableField type in builtin Qt types.
* Key contains field name, value contains field data.
* It can by any type witch support serialization in AMQP types.
*/
typedef QHash<QString, QVariant> TableField;
@ -257,22 +258,22 @@ namespace Frame
* short short long long short remainder...
* @endcode
*
* | Property | Description |
* | ---------- | ----------- |
* | cpContentType | MIME content type |
* | cpContentEncoding | MIME content encoding |
* | cpHeaders | message header field table |
* | cpDeliveryMode| nonpersistent (1) or persistent (2) |
* | cpPriority | message priority, 0 to 9 |
* | cpCorrelationId | application correlation identifier |
* | cpReplyTo | address to reply to |
* | cpExpiration | message expiration specification |
* | cpMessageId | application message identifier |
* | cpTimestamp | message timestamp |
* | cpType | message type name |
* | cpUserId | creating user id |
* | cpAppId | creating application id |
* | cpClusterID| cluster ID |
* | Property | Description |
* | ------------------ | -------------------------------------- |
* | cpContentType | MIME content type |
* | cpContentEncoding | MIME content encoding |
* | cpHeaders | message header field table |
* | cpDeliveryMode | nonpersistent (1) or persistent (2) |
* | cpPriority | message priority, 0 to 9 |
* | cpCorrelationId | application correlation identifier |
* | cpReplyTo | address to reply to |
* | cpExpiration | message expiration specification |
* | cpMessageId | application message identifier |
* | cpTimestamp | message timestamp |
* | cpType | message type name |
* | cpUserId | creating user id |
* | cpAppId | creating application id |
* | cpClusterID | cluster ID |
*
* Default property:
* @sa setProperty