summaryrefslogtreecommitdiff
path: root/cpp
diff options
context:
space:
mode:
authorKenneth Anthony Giusti <kgiusti@apache.org>2011-04-29 20:06:47 +0000
committerKenneth Anthony Giusti <kgiusti@apache.org>2011-04-29 20:06:47 +0000
commit9a632f4313cd04646c9b995142d508aeabc21d88 (patch)
tree54aca744fad7c7ba7df197058d3c14786ed5e4cf /cpp
parent007e56e18b731df8b6232afc3e66c1e8178ae216 (diff)
downloadqpid-python-9a632f4313cd04646c9b995142d508aeabc21d88.tar.gz
QPID-3227: assert if application or reserved header overflows send buffer.
git-svn-id: https://svn.apache.org/repos/asf/qpid/trunk/qpid@1097934 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'cpp')
-rw-r--r--cpp/src/qpid/sys/rdma/RdmaIO.cpp12
-rw-r--r--cpp/src/qpid/sys/rdma/rdma_wrap.h2
2 files changed, 9 insertions, 5 deletions
diff --git a/cpp/src/qpid/sys/rdma/RdmaIO.cpp b/cpp/src/qpid/sys/rdma/RdmaIO.cpp
index af58b7deb0..78bcdec68e 100644
--- a/cpp/src/qpid/sys/rdma/RdmaIO.cpp
+++ b/cpp/src/qpid/sys/rdma/RdmaIO.cpp
@@ -140,7 +140,7 @@ namespace Rdma {
// Prepost recv buffers before we go any further
qp->allocateRecvBuffers(recvBufferCount, bufferSize+FrameHeaderSize);
- // Create xmit buffers
+ // Create xmit buffers, reserve space for frame header.
qp->createSendBuffers(xmitBufferCount, bufferSize, FrameHeaderSize);
}
@@ -210,12 +210,14 @@ namespace Rdma {
}
break;
case 1:
- Buffer* ob = buff ? buff : getSendBuffer();
+ if (!buff)
+ buff = getSendBuffer();
// Add FrameHeader after frame data
FrameHeader header(credit);
- ::memcpy(ob->bytes()+ob->dataCount(), &header, FrameHeaderSize);
- ob->dataCount(ob->dataCount()+FrameHeaderSize);
- qp->postSend(ob);
+ assert(buff->dataCount() <= buff->byteCount()); // ensure app data doesn't impinge on reserved space.
+ ::memcpy(buff->bytes()+buff->dataCount(), &header, FrameHeaderSize);
+ buff->dataCount(buff->dataCount()+FrameHeaderSize);
+ qp->postSend(buff);
break;
}
}
diff --git a/cpp/src/qpid/sys/rdma/rdma_wrap.h b/cpp/src/qpid/sys/rdma/rdma_wrap.h
index 3737664bde..8e3429027b 100644
--- a/cpp/src/qpid/sys/rdma/rdma_wrap.h
+++ b/cpp/src/qpid/sys/rdma/rdma_wrap.h
@@ -77,6 +77,8 @@ namespace Rdma {
}
inline void Buffer::dataCount(int32_t s) {
+ // catch any attempt to overflow a buffer
+ assert(s <= bufferSize + reserved);
sge.length = s;
}