summaryrefslogtreecommitdiff
path: root/indra/llmessage/llpacketring.cpp
diff options
context:
space:
mode:
authorLogan Dethrow <log@lindenlab.com>2011-07-13 11:40:50 -0400
committerLogan Dethrow <log@lindenlab.com>2011-07-13 11:40:50 -0400
commitcfce3686dea74dfa2a6c92dbd1e8e1ae8518f259 (patch)
tree1e3189afbe6d2d9c5b1473ea59399e66a03d5d99 /indra/llmessage/llpacketring.cpp
parentb750a5afb7833d91aed88d9d1f75ee0b4bc2aa80 (diff)
STORM-1112 Fixed network buffers that need to have space for the SOCKS proxy header.
Diffstat (limited to 'indra/llmessage/llpacketring.cpp')
-rw-r--r--indra/llmessage/llpacketring.cpp20
1 files changed, 10 insertions, 10 deletions
diff --git a/indra/llmessage/llpacketring.cpp b/indra/llmessage/llpacketring.cpp
index 91ab1df149..a86b7b4370 100644
--- a/indra/llmessage/llpacketring.cpp
+++ b/indra/llmessage/llpacketring.cpp
@@ -227,13 +227,13 @@ S32 LLPacketRing::receivePacket (S32 socket, char *datap)
// no delay, pull straight from net
if (LLProxy::isEnabled())
{
- U8 buffer[NET_BUFFER_SIZE];
+ U8 buffer[NET_BUFFER_SIZE + SOCKS_HEADER_SIZE];
packet_size = receive_packet(socket, reinterpret_cast<char *>(buffer));
- if (packet_size > 10)
+ if (packet_size > SOCKS_HEADER_SIZE)
{
// *FIX We are assuming ATYP is 0x01 (IPv4), not 0x03 (hostname) or 0x04 (IPv6)
- memcpy(datap, buffer + 10, packet_size - 10);
+ memcpy(datap, buffer + SOCKS_HEADER_SIZE, packet_size - SOCKS_HEADER_SIZE);
proxywrap_t * header = reinterpret_cast<proxywrap_t *>(buffer);
mLastSender.setAddress(header->addr);
mLastSender.setPort(ntohs(header->port));
@@ -274,7 +274,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
BOOL status = TRUE;
if (!mUseOutThrottle)
{
- return doSendPacket(h_socket, send_buffer, buf_size, host );
+ return sendPacketImpl(h_socket, send_buffer, buf_size, host );
}
else
{
@@ -295,7 +295,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
mOutBufferLength -= packetp->getSize();
packet_size = packetp->getSize();
- status = doSendPacket(h_socket, packetp->getData(), packet_size, packetp->getHost());
+ status = sendPacketImpl(h_socket, packetp->getData(), packet_size, packetp->getHost());
delete packetp;
// Update the throttle
@@ -304,7 +304,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
else
{
// If the queue's empty, we can just send this packet right away.
- status = doSendPacket(h_socket, send_buffer, buf_size, host );
+ status = sendPacketImpl(h_socket, send_buffer, buf_size, host );
packet_size = buf_size;
// Update the throttle
@@ -343,7 +343,7 @@ BOOL LLPacketRing::sendPacket(int h_socket, char * send_buffer, S32 buf_size, LL
return status;
}
-BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
+BOOL LLPacketRing::sendPacketImpl(int h_socket, const char * send_buffer, S32 buf_size, LLHost host)
{
if (!LLProxy::isEnabled())
@@ -351,14 +351,14 @@ BOOL LLPacketRing::doSendPacket(int h_socket, const char * send_buffer, S32 buf_
return send_packet(h_socket, send_buffer, buf_size, host.getAddress(), host.getPort());
}
- proxywrap_t *socks_header = (proxywrap_t *)&mProxyWrappedSendBuffer;
+ proxywrap_t *socks_header = reinterpret_cast<proxywrap_t *>(&mProxyWrappedSendBuffer);
socks_header->rsv = 0;
socks_header->addr = host.getAddress();
socks_header->port = htons(host.getPort());
socks_header->atype = ADDRESS_IPV4;
socks_header->frag = 0;
- memcpy(mProxyWrappedSendBuffer + 10, send_buffer, buf_size);
+ memcpy(mProxyWrappedSendBuffer + SOCKS_HEADER_SIZE, send_buffer, buf_size);
- return send_packet(h_socket,(const char*) mProxyWrappedSendBuffer, buf_size + 10, LLProxy::getInstance()->getUDPProxy().getAddress(), LLProxy::getInstance()->getUDPProxy().getPort());
+ return send_packet(h_socket, (const char*) mProxyWrappedSendBuffer, buf_size + 10, LLProxy::getInstance()->getUDPProxy().getAddress(), LLProxy::getInstance()->getUDPProxy().getPort());
}