From: Danny Mayer Date: Tue, 13 Dec 2005 04:35:01 +0000 (-0500) Subject: Fixes for buffer loss and DOS attacks X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=cbe23b0e575262a236ee92f36f50a3c07e3c1cd5;p=thirdparty%2Fntp.git Fixes for buffer loss and DOS attacks bk: 439e4f7554JGPlt8_hEDKpmSKdbssQ --- diff --git a/ports/winnt/include/ntp_iocompletionport.h b/ports/winnt/include/ntp_iocompletionport.h index d02c0f20d6..fa91e0735f 100644 --- a/ports/winnt/include/ntp_iocompletionport.h +++ b/ports/winnt/include/ntp_iocompletionport.h @@ -38,7 +38,7 @@ extern DWORD io_completion_port_sendto (struct interface *, struct pkt *, int, s extern HANDLE get_io_event (void); -struct recvbuf *GetReceivedBuffers(void); +int GetReceivedBuffers(void); static int QueueIORead( struct refclockio * ); diff --git a/ports/winnt/ntpd/ntp_iocompletionport.c b/ports/winnt/ntpd/ntp_iocompletionport.c index d92843aa54..bc55639357 100644 --- a/ports/winnt/ntpd/ntp_iocompletionport.c +++ b/ports/winnt/ntpd/ntp_iocompletionport.c @@ -278,12 +278,16 @@ static unsigned long QueueSocketRecv(SOCKET s) { HEAP_ZERO_MEMORY, sizeof(IoCompletionInfo)); if (lpo == NULL) + { + msyslog(LOG_ERR, "Out of heap memory for recvbufs: %m"); return 0; + } buff = get_free_recv_buffer(); if (buff == NULL) { + msyslog(LOG_ERR, "Out of memory for recvbufs: %m"); HeapFree(hHeapHandle, 0, lpo); return 0; } @@ -357,7 +361,7 @@ OnSocketRecv(DWORD i, IoCompletionInfo *lpo, DWORD Bytes) buff->dstadr = inter; #ifdef DEBUG if (debug > 3) - printf("Received %d bytes from %s\n", stoa(&buff->recv_srcadr)); + printf("Received %d bytes from %s\n", Bytes, stoa(&buff->recv_srcadr)); #endif add_full_recv_buffer(buff); if( !SetEvent( WaitableIoEventHandle ) ) {