Index: CvsProxyUnix.cpp =================================================================== RCS file: /scotty/cvsproxy/CvsProxyUnix.cpp,v retrieving revision 1.22 diff -c -r1.22 CvsProxyUnix.cpp *** CvsProxyUnix.cpp 14 Apr 2020 14:18:23 -0000 1.22 --- CvsProxyUnix.cpp 15 Apr 2020 05:34:33 -0000 *************** *** 100,106 **** static void _receive_thread_proc(SOCKET* s) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) ! CServerIo::trace(3,"Proxy receive thread starting."); #endif int select_errno; --- 100,106 ---- static void _receive_thread_proc(SOCKET* s) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) ! CServerIo::trace(3,"Proxy receive thread starting STDIN_FILENO=%d ,fileno(stdout)=%d.",STDOUT_FILENO,fileno(stdout)); #endif int select_errno; *************** *** 111,116 **** --- 111,121 ---- int len; int lenw; char buf[BUFFER_SIZE]; + unsigned long readbytes; + unsigned long writebytes; + + readbytes=0L; + writebytes=0L; fd_set rfd; timeval tv; *************** *** 128,135 **** g_wait_count=0; if((len=sock.recv(buf,sizeof(buf)))>0) { g_wait_count=0; ! lenw=write(1,buf,len); if(lenw<1) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) --- 133,141 ---- g_wait_count=0; if((len=sock.recv(buf,sizeof(buf)))>0) { + readbytes+=len; g_wait_count=0; ! lenw=write(STDOUT_FILENO,buf,len); if(lenw<1) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) *************** *** 138,143 **** --- 144,150 ---- g_bStop=true; break; } + writebytes+=lenw; } g_wait_count=0; if(len<1) *************** *** 173,179 **** if (g_wait_count>=g_wrwait+g_wswait) g_bStop=true; #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) ! CServerIo::trace(3,"Proxy receive thread end."); #endif } --- 180,186 ---- if (g_wait_count>=g_wrwait+g_wswait) g_bStop=true; #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) ! CServerIo::trace(3,"Proxy receive thread end read=%lu write=%lu.",readbytes,writebytes); #endif } *************** *** 314,320 **** CServerIo::trace(3,"started"); CServerIo::trace(3,"command is: %s %s",argv[0],(argc>=2)?argv[1]:"** none **"); ! uid_t uid; uid = getuid (); if (uid != (uid_t) 0) { --- 321,345 ---- CServerIo::trace(3,"started"); CServerIo::trace(3,"command is: %s %s",argv[0],(argc>=2)?argv[1]:"** none **"); ! CServerIo::trace(3,"Proxy was compiled %s %s", __DATE__, __TIME__); ! ! #ifdef __GNUC__ ! #ifndef __GNUC_PATCHLEVEL__ ! #define __GNUC_PATCHLEVEL__ 0 ! #endif ! #define CVSNT_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) ! CServerIo::trace(3,"Proxy was compiled with GNU C/C++ %d (%s)", CVSNT_GCC_VERSION, __VERSION__); ! #endif ! #ifdef __HP_aCC ! CServerIo::trace(3,"Proxy was compiled with HP aCC C/C++ %d", __HP_aCC); ! #endif ! #ifdef _MSC_VER ! CServerIo::trace(3,"Proxy was compiled with MSVC C/C++ %d", _MSC_VER); ! #endif ! ! CServerIo::trace(3,"Proxy: CVSNT "CVSNT_PRODUCTVERSION_STRING); ! ! uid_t uid; uid = getuid (); if (uid != (uid_t) 0) { *************** *** 742,751 **** --- 767,854 ---- delete[] encbuf; + + #if ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL==1) && (CVSNT_PRODUCT_BUILD>=7347)) + if(sock.recv((char*)&len,sizeof(len))!=sizeof(len)) + { + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::log(CServerIo::logError,DISPLAY_NAMEA" error 0 proxy couldn't rev from preloaded server! [sok.recv(len)]"); + CServerIo::trace(9,"proxy couldn't rev from preloaded server! [sok.recv(len)]"); + #endif + return -1; + } + + if(len<4 || len>1024) // sanity + { + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::log(CServerIo::logError,DISPLAY_NAMEA" error 0 proxy failed sanity check (proxy recv)"); + CServerIo::trace(9,"proxy: failed sanity check (proxy recv)"); + #endif + return -1; + } + + char *recvbuf = new char[len]; + if(sock.recv((char*)recvbuf,len)!=len) + { + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::log(CServerIo::logError,DISPLAY_NAMEA" error 0 proxy: Couldn't read data (proxy recv)"); + CServerIo::trace(9,"proxy: Couldn't read data (proxy recv)"); + #endif + return -1; + } + + if(!bf_set_key(bf_key, sizeof(bf_key))) + { + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::log(CServerIo::logError,DISPLAY_NAMEA" error 0 proxy: decryption key failed (proxy recv)"); + CServerIo::trace(9,"proxy: decryption key failed (proxy recv)"); + #endif + return -1; + } + + if(!bf_decrypt_block(recvbuf,len)) + { + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::log(CServerIo::logError,DISPLAY_NAMEA" error 0 proxy: decryption failed (proxy recv)"); + CServerIo::trace(9,"proxy: decryption failed (proxy recv)"); + #endif + return -1; + } + + if(recvbuf[0]!=2) // data type 2 is the reply at all times + { + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::log(CServerIo::logError,DISPLAY_NAMEA" error 0 proxy: decryption failed data type (proxy recv)"); + CServerIo::trace(9,"proxy: decryption failed data type (proxy recv)"); + #endif + return -1; + } + + PROXY_OK = strdup((const char *)&recvbuf[1]); + PROXY_SESSION = strdup((const char *)&recvbuf[1+reply_iloveu_len]); + delete[] recvbuf; + + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::trace(99,"proxy: server OK \"%s\".",PROXY_OK); + CServerIo::trace(99,"proxy: server session id \"%s\".",PROXY_SESSION); + #endif + #endif // 7347 + + g_bStop=false; SOCKET s = sock.getsocket(); start_receive_thread(&s); + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::trace(3,"Proxy start STDIN_FILENO=%d ,fileno(stdin)=%d.",STDIN_FILENO,fileno(stdin)); + #endif + + unsigned long readbytes; + unsigned long writebytes; + + readbytes=0L; + writebytes=0L; + if (g_simpler_proxy) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) *************** *** 753,765 **** #endif // assume you can't do select() in stdin, so the check for g_bStop is somewhat // useless... ! while(!g_bStop && (len=read(0,buf,sizeof(buf)))>0) if(sock.send(buf,len)<1) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) CServerIo::trace(3,"Proxy (simpler) failed to send to local port 32999."); #endif break; } #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) CServerIo::trace(3,"Proxy (simpler) stopping."); --- 856,872 ---- #endif // assume you can't do select() in stdin, so the check for g_bStop is somewhat // useless... ! while(!g_bStop && (len=read(STDIN_FILENO,buf,sizeof(buf)))>0) ! { ! readbytes+=len; if(sock.send(buf,len)<1) { #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) CServerIo::trace(3,"Proxy (simpler) failed to send to local port 32999."); #endif break; } + writebytes+=len; + } #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) CServerIo::trace(3,"Proxy (simpler) stopping."); *************** *** 782,796 **** tv.tv_usec=0; FD_ZERO(&rfd); ! FD_SET(0,&rfd); ! while(g_wait_count=0)) { ! if(FD_ISSET(0,&rfd)) { g_wait_count=0; ! if((len=read(0,buf,sizeof(buf)))>0) { g_wait_count=0; if(sock.send(buf,len)<1) { --- 889,904 ---- tv.tv_usec=0; FD_ZERO(&rfd); ! FD_SET(STDIN_FILENO,&rfd); ! while(g_wait_count=0)) { ! if(FD_ISSET(STDIN_FILENO,&rfd)) { g_wait_count=0; ! if((len=read(STDIN_FILENO,buf,sizeof(buf)))>0) { + readbytes+=len; g_wait_count=0; if(sock.send(buf,len)<1) { *************** *** 799,804 **** --- 907,913 ---- #endif break; } + writebytes+=len; } else #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) *************** *** 818,824 **** g_wait_count++; FD_ZERO(&rfd); ! FD_SET(0,&rfd); tv.tv_sec=1; tv.tv_usec=0; --- 927,933 ---- g_wait_count++; FD_ZERO(&rfd); ! FD_SET(STDIN_FILENO,&rfd); tv.tv_sec=1; tv.tv_usec=0; *************** *** 838,843 **** --- 947,955 ---- #endif } // g_simpler_proxy + #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) + CServerIo::trace(3,"Proxy read=%lu write=%lu.",readbytes,writebytes); + #endif g_bStop=true; #if ( ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL>=2)) || (defined(CVSNT_ENABLE_CLIENT_LOG)) ) CServerIo::trace(3,"Proxy now close the socket."); Index: CvsProxyWin32.cpp =================================================================== RCS file: /scotty/cvsproxy/CvsProxyWin32.cpp,v retrieving revision 1.18 diff -c -r1.18 CvsProxyWin32.cpp *** CvsProxyWin32.cpp 9 Apr 2020 11:23:01 -0000 1.18 --- CvsProxyWin32.cpp 15 Apr 2020 05:34:33 -0000 *************** *** 47,52 **** --- 47,53 ---- time_t g_session_time_t; char *g_trace_file; FILE *g_trace_file_fp; + const char *PROXY_OK, *PROXY_SESSION; CVSPRX_EXPORT int wmain(int argc, wchar_t* argv[]); *************** *** 230,235 **** --- 231,254 ---- int wmain2(int argc, wchar_t *argv[], LPCSTR crashcmda, const char *ErrUserName, const DWORD len) { + CServerIo::trace(3,"Proxy was compiled %s %s", __DATE__, __TIME__); + + #ifdef __GNUC__ + #ifndef __GNUC_PATCHLEVEL__ + #define __GNUC_PATCHLEVEL__ 0 + #endif + #define CVSNT_GCC_VERSION (__GNUC__ * 10000 + __GNUC_MINOR__ * 100 + __GNUC_PATCHLEVEL__) + CServerIo::trace(3,"Proxy was compiled with GNU C/C++ %d (%s)", CVSNT_GCC_VERSION, __VERSION__); + #endif + #ifdef __HP_aCC + CServerIo::trace(3,"Proxy was compiled with HP aCC C/C++ %d", __HP_aCC); + #endif + #ifdef _MSC_VER + CServerIo::trace(3,"Proxy was compiled with MSVC C/C++ %d", _MSC_VER); + #endif + + CServerIo::trace(3,"Proxy: CVSNT "CVSNT_PRODUCTVERSION_STRING); + CServerIo::trace(3,"wmain 2, is this server or client?"); if(argc>=2 && !wcscmp(argv[1],L"server")) { *************** *** 475,480 **** --- 494,501 ---- DWORD len=sizeof(ErrUserName); LPSTR crashcmda; + PROXY_OK=NULL; + PROXY_SESSION=NULL; doClientTraceFile(); CServerIo::trace(3,"wmain2 started"); *************** *** 549,558 **** --- 570,583 ---- int wrwait=120; int wswait=120; int noproxywait=0; + unsigned char reply_iloveu[] = "I LOVE YOU"; + int reply_iloveu_len; if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","RCVTIMEO",bufferw,sizeof(bufferw))) wrwait = atoi(bufferw); if(!CGlobalSettings::GetGlobalValue("cvsnt","PServer","SNDTIMEO",bufferw,sizeof(bufferw))) wswait = atoi(bufferw); + reply_iloveu_len=(int)strlen((const char *)&reply_iloveu[0])+1; + // I'm seeing some intermittent commit problems on the WinXP client - so adding this // just as a test case... *************** *** 567,578 **** if(!sock_create_result) { ! printf("error 0 Couldn't connect to server - is it running?\n"); return -1; } if(!sock.connect()) { ! printf("error 0 Couldn't connect to server - is it running?\n"); return -1; } --- 592,605 ---- if(!sock_create_result) { ! CServerIo::log(CServerIo::logError,"proxy couldn't connect to server - is it running? [sock_create_result]"); ! CServerIo::trace(3,"error 0 Couldn't connect to server - is it running? [sock_create_result]"); return -1; } if(!sock.connect()) { ! CServerIo::log(CServerIo::logError,"proxy couldn't connect to server - is it running? [sock.connect]"); ! CServerIo::trace(3,"error 0 Couldn't connect to server - is it running? [sock.connect]"); return -1; } *************** *** 595,617 **** memcpy(encbuf+1,name,strlen(name)+1); memcpy(encbuf+1+strlen(name)+1,"MHSL",4); ! bf_set_key(bf_key,sizeof(bf_key)); bf_encrypt_block(encbuf,len); // Endianness doesn't matter here because we always proxy to localhost if(sock.send((const char *)&len,sizeof(len))!=sizeof(len)) { ! printf("error 0 Failed writing to server\n"); ! return -1; } if(sock.send(encbuf,len)!=len) { ! printf("error 0 Failed writing to server\n"); ! return -1; } delete[] encbuf; delete[] name; g_bStop=false; SOCKET s = sock.getsocket(); --- 622,704 ---- memcpy(encbuf+1,name,strlen(name)+1); memcpy(encbuf+1+strlen(name)+1,"MHSL",4); ! if(!bf_set_key(bf_key, sizeof(bf_key))) ! { ! CServerIo::log(CServerIo::logError,"proxy: decryption key failed (proxy send)"); ! CServerIo::trace(9,"proxy: decryption key failed (proxy send)"); ! return -1; ! } ! bf_encrypt_block(encbuf,len); // Endianness doesn't matter here because we always proxy to localhost if(sock.send((const char *)&len,sizeof(len))!=sizeof(len)) { ! CServerIo::log(CServerIo::logError,"proxy couldn't send to preloaded server! [sok.send(len)]"); ! CServerIo::trace(3,"proxy couldn't send to preloaded server! [sok.send(len)]"); ! return -1; } if(sock.send(encbuf,len)!=len) { ! CServerIo::log(CServerIo::logError,"proxy couldn't send to preloaded server! [sok.send(data)]"); ! CServerIo::trace(3,"proxy couldn't send to preloaded server! [sok.send(data)]"); ! return -1; } delete[] encbuf; delete[] name; + + #if ((CVSNT_PRODUCT_MAJOR==2) && (CVSNT_PRODUCT_MINOR==8) && (CVSNT_PRODUCT_PATCHLEVEL==1) && (CVSNT_PRODUCT_BUILD>=7347)) + if(sock.recv((char*)&len,sizeof(len))!=sizeof(len)) + { + CServerIo::log(CServerIo::logError,"proxy couldn't rev from preloaded server! [sok.recv(len)]"); + CServerIo::trace(9,"proxy couldn't rev from preloaded server! [sok.recv(len)]"); + return -1; + } + + if(len<4 || len>1024) // sanity + { + CServerIo::log(CServerIo::logError,"proxy failed sanity check (proxy recv)"); + CServerIo::trace(9,"proxy: failed sanity check (proxy recv)"); + return -1; + } + + char *recvbuf = new char[len]; + if(sock.recv((char*)recvbuf,len)!=len) + { + CServerIo::log(CServerIo::logError,"proxy: Couldn't read data (proxy recv)"); + CServerIo::trace(9,"proxy: Couldn't read data (proxy recv)"); + return -1; + } + + if(!bf_set_key(bf_key, sizeof(bf_key))) + { + CServerIo::log(CServerIo::logError,"proxy: decryption key failed (proxy recv)"); + CServerIo::trace(9,"proxy: decryption key failed (proxy recv)"); + return -1; + } + + if(!bf_decrypt_block(recvbuf,len)) + { + CServerIo::log(CServerIo::logError,"proxy: decryption failed (proxy recv)"); + CServerIo::trace(9,"proxy: decryption failed (proxy recv)"); + return -1; + } + + if(recvbuf[0]!=2) // data type 2 is the reply at all times + { + CServerIo::log(CServerIo::logError,"proxy: decryption failed data type (proxy recv)"); + CServerIo::trace(9,"proxy: decryption failed data type (proxy recv)"); + return -1; + } + + PROXY_OK = strdup((const char *)&recvbuf[1]); + PROXY_SESSION = strdup((const char *)&recvbuf[1+reply_iloveu_len]); + delete[] recvbuf; + + CServerIo::trace(99,"proxy: server OK \"%s\".",PROXY_OK); + CServerIo::trace(99,"proxy: server session id \"%s\".",PROXY_SESSION); + #endif // 7347 g_bStop=false; SOCKET s = sock.getsocket(); Index: build.h =================================================================== RCS file: /cvs/cvsnt/build.h,v retrieving revision 1.1.2.173.4.320.2.295 diff -c -r1.1.2.173.4.320.2.295 build.h *** build.h 14 Apr 2020 05:29:14 -0000 1.1.2.173.4.320.2.295 --- build.h 15 Apr 2020 01:27:00 -0000 *************** *** 1 **** ! #define CVSNT_PRODUCT_BUILD 7346 --- 1 ---- ! #define CVSNT_PRODUCT_BUILD 7347 Index: src/server.cpp =================================================================== RCS file: /cvs/cvsnt/src/server.c,v retrieving revision 1.106.2.210.6.99.2.64 diff -c -r1.106.2.210.6.99.2.64 server.cpp *** src/server.cpp 9 Apr 2020 06:20:20 -0000 1.106.2.210.6.99.2.64 --- src/server.cpp 15 Apr 2020 05:11:11 -0000 *************** *** 656,662 **** struct timeval tv = { wrwait,0 }; FD_ZERO(&fdr); FD_SET(server_io_socket,&fdr); ! selecterr = select(server_io_socket,&fdr,NULL,NULL,&tv); if(selecterr!=1) { TRACE(99,"client_protocol_buffer_input() select appears to timeout after %d seconds, err=%d",wrwait,selecterr); --- 656,662 ---- struct timeval tv = { wrwait,0 }; FD_ZERO(&fdr); FD_SET(server_io_socket,&fdr); ! selecterr = select(server_io_socket+1,&fdr,NULL,NULL,&tv); if(selecterr!=1) { TRACE(99,"client_protocol_buffer_input() select appears to timeout after %d seconds, err=%d",wrwait,selecterr); *************** *** 2155,2161 **** struct timeval tv = { wrwait,0 }; FD_ZERO(&fdr); FD_SET(server_io_socket,&fdr); ! selecterr = select(server_io_socket,&fdr,NULL,NULL,&tv); if(selecterr!=1) { #ifdef _WIN32 --- 2155,2161 ---- struct timeval tv = { wrwait,0 }; FD_ZERO(&fdr); FD_SET(server_io_socket,&fdr); ! selecterr = select(server_io_socket+1,&fdr,NULL,NULL,&tv); if(selecterr!=1) { #ifdef _WIN32 *************** *** 7388,7393 **** --- 7388,7394 ---- }; int len; unsigned char *buf; + unsigned char reply_iloveu[] = "I LOVE YOU"; CServerIo::trace(99,"proxy: proxy_authenticate_connection"); if(s->recv((char*)&len,sizeof(len))!=sizeof(len)) *************** *** 7398,7404 **** if(len<4 || len>1024) // sanity { ! CServerIo::trace(9,"proxy: failed sanity check"); return -1; } --- 7399,7405 ---- if(len<4 || len>1024) // sanity { ! CServerIo::trace(9,"proxy: failed sanity check (preload recv)"); return -1; } *************** *** 7425,7433 **** --- 7426,7465 ---- } CVS_Username = xstrdup((const char *)&buf[1]); + CServerIo::trace(99,"proxy: proxy_authenticate_connection got \"%s\".",CVS_Username); xfree(buf); + len=(int)strlen((const char *)&reply_iloveu[0])+1; + len+=(int)strlen(PATCH_NULL(global_session_id))+1; + len+=1+5; // For type byte + trailer + if(len%8) + len+=8-(len&7); + buf=(unsigned char *)xmalloc(len); + + *buf=1; // Data type 2, not the same as data type 1 + memcpy(buf+1,reply_iloveu,strlen((const char *)&reply_iloveu[0])+1); + memcpy(buf+1+strlen((const char *)&reply_iloveu[0])+1,PATCH_NULL(global_session_id),strlen(PATCH_NULL(global_session_id))+1); + memcpy(buf+1+strlen((const char *)&reply_iloveu[0])+1+strlen(PATCH_NULL(global_session_id))+1,"MHSL",4); + + if(!bf_set_key(bf_key, sizeof(bf_key))) + return -1; + + bf_encrypt_block(buf,len); + + CServerIo::trace(99,"proxy: proxy_authenticate_connection send \"%s\".",reply_iloveu); + if(s->send((const char *)&len,sizeof(len))!=sizeof(len)) + { + CServerIo::trace(9,"proxy: initial send OK (len) failed"); + return -1; + } + if(s->send((const char *)buf,len)!=len) + { + CServerIo::trace(9,"proxy: initial send OK (data) failed"); + return -1; + } + + CServerIo::trace(99,"proxy: proxy_authenticate_connection - set up protocol buffers."); /* We want errors to go over the server protocol channel, so create a fake io buffer */ buf_from_net = client_protocol_buffer_initialize (NULL, 1, outbuf_memory_error); Index: src/subr.cpp =================================================================== RCS file: /cvs/cvsnt/src/subr.c,v retrieving revision 1.62.2.81.6.19.2.17 diff -c -r1.62.2.81.6.19.2.17 subr.cpp *** src/subr.cpp 22 Jun 2016 08:10:03 -0000 1.62.2.81.6.19.2.17 --- src/subr.cpp 15 Apr 2020 05:11:11 -0000 *************** *** 1549,1555 **** struct timeval tv = { 0,1000 }; FD_ZERO(&fds); FD_SET(sock,&fds); ! err = select(sock,NULL,&fds,NULL,&tv); if(err!=1) { if(!supress_errors) --- 1549,1555 ---- struct timeval tv = { 0,1000 }; FD_ZERO(&fds); FD_SET(sock,&fds); ! err = select(sock+1,NULL,&fds,NULL,&tv); if(err!=1) { if(!supress_errors)