Author: pschweitzer
Date: Sun Apr 6 12:44:10 2014
New Revision: 62648
URL:
http://svn.reactos.org/svn/reactos?rev=62648&view=rev
Log:
[TCPSVCS]
- Fix buffer overrun
- Fix memory leak
- Properly init memory
CID #511073
CID #1102322
CID #1102405
Modified:
trunk/reactos/base/services/tcpsvcs/qotd.c
trunk/reactos/base/services/tcpsvcs/skelserver.c
Modified: trunk/reactos/base/services/tcpsvcs/qotd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/tcpsvcs/qotd…
==============================================================================
--- trunk/reactos/base/services/tcpsvcs/qotd.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/tcpsvcs/qotd.c [iso-8859-1] Sun Apr 6 12:44:10 2014
@@ -58,7 +58,7 @@
else
{
DWORD dwSize = GetFileSize(hFile, NULL);
- lpQuotes = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dwSize);
+ lpQuotes = (LPSTR)HeapAlloc(GetProcessHeap(), 0, dwSize + 1);
if (!lpQuotes)
{
CloseHandle(hFile);
@@ -75,7 +75,10 @@
lpQuotes[dwSize] = 0;
if (dwBytesRead != dwSize)
+ {
+ HeapFree(GetProcessHeap(), 0, lpQuotes);
return FALSE;
+ }
lpStr = lpQuotes;
while (*lpStr)
@@ -120,6 +123,7 @@
}
}
+ HeapFree(GetProcessHeap(), 0, lpQuotes);
return TRUE;
}
Modified: trunk/reactos/base/services/tcpsvcs/skelserver.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/services/tcpsvcs/skel…
==============================================================================
--- trunk/reactos/base/services/tcpsvcs/skelserver.c [iso-8859-1] (original)
+++ trunk/reactos/base/services/tcpsvcs/skelserver.c [iso-8859-1] Sun Apr 6 12:44:10
2014
@@ -21,6 +21,7 @@
sock = socket(AF_INET, SOCK_STREAM, 0);
if (sock != INVALID_SOCKET)
{
+ ZeroMemory(&server, sizeof(SOCKADDR_IN));
server.sin_family = AF_INET;
server.sin_addr.s_addr = htonl(INADDR_ANY);
server.sin_port = Port;