I am writing a web proxy, and it is working great with web pages that can be translated to ASCII text. However, when I try to view pages with binary data (Youtube.com is the one I've been using), there is a memory leak someplace, and the same few characters will repeat over and over again at the end of the strings I'm sending to the client (and will show up in other places where they clearly shouldn't be).
Below is the relevant part of my code. SendHTTPResponse is a function that sends the response of the web page to the client using the proxy, and works correctly.
Does anyone have any insight?
int numBytes;
char temp[3000];
memset(temp, '\0', 3000);
numBytes = Read(internetSocket, temp, 2999);
while (errno = 0, numBytes > 0 || errno == EINTR)
{
SendHTTPResponse(socket, temp, numBytes);
memset(temp, '\0', 3000);
numBytes = Read(internetSocket, temp, 2999);
}