mirror of
https://github.com/The-Powder-Toy/The-Powder-Toy.git
synced 2025-08-21 23:45:20 +02:00
Fix over-eager MSVCRT bounds checking crash in LuaTCPSocket
MSVCRT doesn't like .operator[](.size()), it's safer to just replace all &.operator[x] with &.operator[0]+x.
This commit is contained in:
@@ -205,7 +205,7 @@ namespace LuaTCPSocket
|
|||||||
CURLcode res = CURLE_OK;
|
CURLcode res = CURLE_OK;
|
||||||
if (!tcps->writeClosed)
|
if (!tcps->writeClosed)
|
||||||
{
|
{
|
||||||
res = curl_easy_send(tcps->easy, &data[writtenTotal], len - writtenTotal, &writtenNow);
|
res = curl_easy_send(tcps->easy, &data[0] + writtenTotal, len - writtenTotal, &writtenNow);
|
||||||
}
|
}
|
||||||
writtenTotal += writtenNow;
|
writtenTotal += writtenNow;
|
||||||
if (writtenTotal >= len)
|
if (writtenTotal >= len)
|
||||||
@@ -299,7 +299,7 @@ namespace LuaTCPSocket
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
res = curl_easy_recv(tcps->easy, &tcps->recvBuf[readTotal], len - readTotal, &readNow);
|
res = curl_easy_recv(tcps->easy, &tcps->recvBuf[0] + readTotal, len - readTotal, &readNow);
|
||||||
}
|
}
|
||||||
readTotal += readNow;
|
readTotal += readNow;
|
||||||
returning = readTotal;
|
returning = readTotal;
|
||||||
@@ -410,8 +410,8 @@ namespace LuaTCPSocket
|
|||||||
// of view of an "*l" pattern). Handling this edge case in a special,
|
// of view of an "*l" pattern). Handling this edge case in a special,
|
||||||
// sub-quadratic way isn't worth the effort.
|
// sub-quadratic way isn't worth the effort.
|
||||||
std::copy(
|
std::copy(
|
||||||
&tcps->recvBuf[readTotal - tcps->stashedLen],
|
&tcps->recvBuf[0] + readTotal - tcps->stashedLen,
|
||||||
&tcps->recvBuf[readTotal],
|
&tcps->recvBuf[0] + readTotal,
|
||||||
&tcps->recvBuf[0]
|
&tcps->recvBuf[0]
|
||||||
);
|
);
|
||||||
return retn;
|
return retn;
|
||||||
|
Reference in New Issue
Block a user