--- parser3/src/lib/smtp/smtp.C 2004/02/24 11:10:05 1.4 +++ parser3/src/lib/smtp/smtp.C 2023/09/26 20:49:09 1.16 @@ -1,21 +1,21 @@ /** @file Parser: SMTP sender. - Copyright (c) 2001-2004 ArtLebedev Group (http://www.artlebedev.com) - Author: Alexandr Petrosian (http://paf.design.ru) + Copyright (c) 2001-2023 Art. Lebedev Studio (http://www.artlebedev.com) + Authors: Konstantin Morshnev , Alexandr Petrosian Parts of the code here is based upon an early gensock and blat */ -static const char * const IDENT_SMTP_C="$Date: 2004/02/24 11:10:05 $"; - #include "pa_exception.h" #include "smtp.h" -#undef snprintf +volatile const char * IDENT_SMTP_C="$Id: smtp.C,v 1.16 2023/09/26 20:49:09 moko Exp $" IDENT_SMTP_H; + // pa_common.C -extern int __snprintf(char *, size_t, const char* , ...); -#define snprintf __snprintf +#undef snprintf +extern int pa_snprintf(char *, size_t, const char* , ...); +#define snprintf pa_snprintf //#define DEBUG_SHOW @@ -27,15 +27,15 @@ SMTP::SMTP() { in_buffer_total = 0; out_buffer_total = 0; - in_buffer = (char *)malloc(SOCKET_BUFFER_SIZE); - out_buffer = (char *)malloc(SOCKET_BUFFER_SIZE); + in_buffer = (char *)pa_malloc(SOCKET_BUFFER_SIZE); + out_buffer = (char *)pa_malloc(SOCKET_BUFFER_SIZE); last_winsock_error = 0; } SMTP::~SMTP() { - free(in_buffer); - free(out_buffer); + pa_free(in_buffer); + pa_free(out_buffer); } @@ -44,6 +44,7 @@ void SMTP:: ConnectToHost(const char* hostname, const char* service) { struct sockaddr_in sa_in; + memset(&sa_in, 0, sizeof(sa_in)); u_short our_port; if( !ResolveService(service, &our_port) ) @@ -95,9 +96,9 @@ GetBuffer(int wait) timeout.tv_sec = 30; } - if( (retval = select(0, &fds, NULL, NULL, &timeout))<0 ) + if( (retval = select(1+the_socket, &fds, NULL, NULL, &timeout))<0 ) { -#ifdef WIN32 +#ifdef _MSC_VER int error_code = WSAGetLastError(); if( error_code == WSAEINPROGRESS && wait ) @@ -227,7 +228,7 @@ SendLine(const char* data, unsigned long while( length > 0 ) { - if( select(0, NULL, &fds, NULL, &timeout)<0 ) + if( select(1+the_socket, NULL, &fds, NULL, &timeout)<0 ) throw Exception("smtp.execute", 0, "connection::put_data() unexpected error from select: %d",