Compilation warnings cleanup

This commit is contained in:
z3APA3A 2016-02-16 15:29:51 +03:00
parent f70a8c0019
commit 3b8e7741b3
21 changed files with 173 additions and 172 deletions

View File

@ -13,7 +13,7 @@ CC = gcc
CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6 CFLAGS = -O2 -s -c -mthreads -DWITH_STD_MALLOC -DNOIPV6
COUT = -o COUT = -o
LN = gcc LN = gcc
LDFLAGS = -O2 -s -mthreads LDFLAGS = -O2 -s -mthreads
DLFLAGS = -shared DLFLAGS = -shared
DLSUFFICS = .dll DLSUFFICS = .dll
LIBS = -lws2_32 -lodbc32 -ladvapi32 LIBS = -lws2_32 -lodbc32 -ladvapi32

View File

@ -87,7 +87,7 @@ void __stdcall CommandHandler( DWORD dwCommand )
void __stdcall ServiceMain(int argc, unsigned char* argv[] ) void __stdcall ServiceMain(int argc, unsigned char* argv[] )
{ {
hSrv = RegisterServiceCtrlHandler(conf.stringtable[1], (LPHANDLER_FUNCTION)CommandHandler); hSrv = RegisterServiceCtrlHandler((LPCSTR)conf.stringtable[1], (LPHANDLER_FUNCTION)CommandHandler);
if( hSrv == 0 ) return; if( hSrv == 0 ) return;
SetStatus( SERVICE_START_PENDING, 0, 1 ); SetStatus( SERVICE_START_PENDING, 0, 1 );
@ -394,7 +394,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
"By clicking Yes you confirm you read and accepted License Agreement.\n" "By clicking Yes you confirm you read and accepted License Agreement.\n"
"You can use Administration/Services to control %s service.", "You can use Administration/Services to control %s service.",
conf.stringtable[1], conf.stringtable[2]); conf.stringtable[1], conf.stringtable[2]);
if(MessageBox(NULL, (char *)tmpbuf, conf.stringtable[2], MB_YESNO|MB_ICONASTERISK) != IDYES) return 1; if(MessageBox(NULL, (LPCSTR)tmpbuf, (LPCSTR)conf.stringtable[2], MB_YESNO|MB_ICONASTERISK) != IDYES) return 1;
*tmpbuf = '\"'; *tmpbuf = '\"';
@ -415,7 +415,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
perror("Failed to open Service Manager"); perror("Failed to open Service Manager");
RETURN(101); RETURN(101);
} }
if (!(sch = CreateService(sch, conf.stringtable[1], conf.stringtable[2], GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, (char *)tmpbuf, NULL, NULL, NULL, NULL, NULL))){ if (!(sch = CreateService(sch, (LPCSTR)conf.stringtable[1], (LPCSTR)conf.stringtable[2], GENERIC_EXECUTE, SERVICE_WIN32_OWN_PROCESS, SERVICE_AUTO_START, SERVICE_ERROR_IGNORE, (char *)tmpbuf, NULL, NULL, NULL, NULL, NULL))){
perror("Failed to create service"); perror("Failed to create service");
RETURN(103); RETURN(103);
} }
@ -436,10 +436,10 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
RETURN(104); RETURN(104);
} }
if(RegSetValueEx( runsrv, if(RegSetValueEx( runsrv,
conf.stringtable[1], (LPCSTR)conf.stringtable[1],
0, 0,
REG_EXPAND_SZ, REG_EXPAND_SZ,
(char *)tmpbuf, (BYTE *)tmpbuf,
(int)strlen((char *)tmpbuf)+1)!=ERROR_SUCCESS){ (int)strlen((char *)tmpbuf)+1)!=ERROR_SUCCESS){
perror("Failed to set registry value"); perror("Failed to set registry value");
RETURN(105); RETURN(105);
@ -457,7 +457,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
perror("Failed to open Service Manager\n"); perror("Failed to open Service Manager\n");
RETURN(106); RETURN(106);
} }
if (!(sch = OpenService(sch, conf.stringtable[1], DELETE))){ if (!(sch = OpenService(sch, (LPCSTR)conf.stringtable[1], DELETE))){
perror("Failed to open service"); perror("Failed to open service");
RETURN(107); RETURN(107);
} }
@ -476,7 +476,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
perror("Failed to open registry"); perror("Failed to open registry");
RETURN(109); RETURN(109);
} }
if(RegDeleteValue(runsrv, conf.stringtable[1]) != ERROR_SUCCESS){ if(RegDeleteValue(runsrv, (LPCSTR)conf.stringtable[1]) != ERROR_SUCCESS){
perror("Failed to clear registry"); perror("Failed to clear registry");
RETURN(110); RETURN(110);
} }
@ -528,7 +528,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
if(service){ if(service){
SERVICE_TABLE_ENTRY ste[] = SERVICE_TABLE_ENTRY ste[] =
{ {
{ conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain}, { (LPSTR)conf.stringtable[1], (LPSERVICE_MAIN_FUNCTION)ServiceMain},
{ NULL, NULL } { NULL, NULL }
}; };
if(!StartServiceCtrlDispatcher( ste ))cyclestep(); if(!StartServiceCtrlDispatcher( ste ))cyclestep();

View File

@ -43,9 +43,9 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
len = sprintf((char *)buf, "CONNECT "); len = sprintf((char *)buf, "CONNECT ");
if(redir->type == R_CONNECTP && param->hostname) { if(redir->type == R_CONNECTP && param->hostname) {
char * needreplace; char * needreplace;
needreplace = strchr(param->hostname, ':'); needreplace = strchr((char *)param->hostname, ':');
if(needreplace) buf[len++] = '['; if(needreplace) buf[len++] = '[';
len =+ sprintf((char *)buf + len, "%.256s", param->hostname); len += sprintf((char *)buf + len, "%.256s", (char *)param->hostname);
if(needreplace) buf[len++] = ']'; if(needreplace) buf[len++] = ']';
} }
else { else {
@ -372,19 +372,19 @@ int ACLmatches(struct ace* acentry, struct clientparam * param){
for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){ for(hstentry = acentry->dstnames; hstentry; hstentry = hstentry->next){
switch(hstentry->matchtype){ switch(hstentry->matchtype){
case 0: case 0:
if(strstr(param->hostname, hstentry->name)) match = 1; if(strstr((char *)param->hostname, (char *)hstentry->name)) match = 1;
break; break;
case 1: case 1:
if(strstr(param->hostname, hstentry->name) == (char *)param->hostname) match = 1; if(strstr((char *)param->hostname, (char *)hstentry->name) == (char *)param->hostname) match = 1;
break; break;
case 2: case 2:
if(strstr(param->hostname, hstentry->name) == (char *)(param->hostname + i - (strlen(hstentry->name)))) match = 1; if(strstr((char *)param->hostname, (char *)hstentry->name) == (char *)(param->hostname + i - (strlen((char *)hstentry->name)))) match = 1;
break; break;
default: default:
if(!strcmp(param->hostname, hstentry->name)) match = 1; if(!strcmp((char *)param->hostname, (char *)hstentry->name)) match = 1;
break; break;
} }
if(match) break; if(match) break;
@ -654,13 +654,13 @@ int cacheauth(struct clientparam * param){
continue; continue;
} }
if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, param->username))) && if(((!(conf.authcachetype&2)) || (param->username && ac->username && !strcmp(ac->username, (char *)param->username))) &&
((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), &param->sincr, SAADDRLEN(&ac->sa)))) && ((!(conf.authcachetype&1)) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), &param->sincr, SAADDRLEN(&ac->sa)))) &&
(!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, param->password)))) { (!(conf.authcachetype&4) || (ac->password && param->password && !strcmp(ac->password, (char *)param->password)))) {
if(param->username){ if(param->username){
myfree(param->username); myfree(param->username);
} }
param->username = mystrdup(ac->username); param->username = (unsigned char *)mystrdup(ac->username);
pthread_mutex_unlock(&hash_mutex); pthread_mutex_unlock(&hash_mutex);
return 0; return 0;
} }
@ -688,18 +688,18 @@ int doauth(struct clientparam * param){
if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){ if(conf.authcachetype && authfuncs->authenticate && authfuncs->authenticate != cacheauth && param->username && (!(conf.authcachetype&4) || (!param->pwtype && param->password))){
pthread_mutex_lock(&hash_mutex); pthread_mutex_lock(&hash_mutex);
for(ac = authc; ac; ac = ac->next){ for(ac = authc; ac; ac = ac->next){
if((!(conf.authcachetype&2) || !strcmp(ac->username, param->username)) && if((!(conf.authcachetype&2) || !strcmp(ac->username, (char *)param->username)) &&
(!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), &param->sincr, SAADDRLEN(&ac->sa)))) && (!(conf.authcachetype&1) || (*SAFAMILY(&ac->sa) == *SAFAMILY(&param->sincr) && !memcmp(SAADDR(&ac->sa), &param->sincr, SAADDRLEN(&ac->sa)))) &&
(!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, param->password)))) { (!(conf.authcachetype&4) || (ac->password && !strcmp(ac->password, (char *)param->password)))) {
ac->expires = conf.time + conf.authcachetime; ac->expires = conf.time + conf.authcachetime;
if(strcmp(ac->username, param->username)){ if(strcmp(ac->username, (char *)param->username)){
tmp = ac->username; tmp = ac->username;
ac->username = mystrdup(param->username); ac->username = mystrdup((char *)param->username);
myfree(tmp); myfree(tmp);
} }
if((conf.authcachetype&4)){ if((conf.authcachetype&4)){
tmp = ac->password; tmp = ac->password;
ac->password = mystrdup(param->password); ac->password = mystrdup((char *)param->password);
myfree(tmp); myfree(tmp);
} }
ac->sa = param->sincr; ac->sa = param->sincr;
@ -710,10 +710,10 @@ int doauth(struct clientparam * param){
ac = myalloc(sizeof(struct authcache)); ac = myalloc(sizeof(struct authcache));
if(ac){ if(ac){
ac->expires = conf.time + conf.authcachetime; ac->expires = conf.time + conf.authcachetime;
ac->username = mystrdup(param->username); ac->username = mystrdup((char *)param->username);
ac->sa = param->sincr; ac->sa = param->sincr;
ac->password = NULL; ac->password = NULL;
if((conf.authcachetype&4) && param->password) ac->password = mystrdup(param->password); if((conf.authcachetype&4) && param->password) ac->password = mystrdup((char *)param->password);
} }
ac->next = authc; ac->next = authc;
authc = ac; authc = ac;
@ -775,7 +775,7 @@ int dnsauth(struct clientparam * param){
((u&0xFF000000)>>24)); ((u&0xFF000000)>>24));
} }
if(!udpresolve(*SAFAMILY(&param->sincr), buf, addr, NULL, param, 1)) return 6; if(!udpresolve(*SAFAMILY(&param->sincr), (unsigned char *)buf, (unsigned char *)addr, NULL, param, 1)) return 6;
if(!memcmp(SAADDR(&param->sincr), addr, SAADDRLEN(&param->sincr))) return 6; if(!memcmp(SAADDR(&param->sincr), addr, SAADDRLEN(&param->sincr))) return 6;
return param->username? 0:4; return param->username? 0:4;
@ -1187,7 +1187,7 @@ unsigned long udpresolve(int af, unsigned char * name, unsigned char * value, un
} }
*s2 = 0; *s2 = 0;
if(param->username)myfree(param->username); if(param->username)myfree(param->username);
param->username = mystrdup (buf + k + 13); param->username = (unsigned char *)mystrdup ((char *)buf + k + 13);
return udpresolve(af,param->username, value, NULL, NULL, 2); return udpresolve(af,param->username, value, NULL, NULL, 2);
} }
@ -1324,20 +1324,20 @@ void logsql(struct clientparam * param, const unsigned char *s) {
if(param->nolog) return; if(param->nolog) return;
pthread_mutex_lock(&log_mutex); pthread_mutex_lock(&log_mutex);
len = dobuf(param, tmpbuf, s, "\'"); len = dobuf(param, tmpbuf, s, (unsigned char *)"\'");
if(attempt > 5){ if(attempt > 5){
time_t t; time_t t;
t = time(0); t = time(0);
if (t - attempt_time < 180){ if (t - attempt_time < 180){
sqlerr(tmpbuf); sqlerr((char *)tmpbuf);
return; return;
} }
} }
if(!hstmt){ if(!hstmt){
if(!init_sql(sqlstring)) { if(!init_sql(sqlstring)) {
sqlerr(tmpbuf); sqlerr((char *)tmpbuf);
return; return;
} }
} }
@ -1346,13 +1346,13 @@ void logsql(struct clientparam * param, const unsigned char *s) {
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){ if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
close_sql(); close_sql();
if(!init_sql(sqlstring)){ if(!init_sql(sqlstring)){
sqlerr(tmpbuf); sqlerr((char *)tmpbuf);
return; return;
} }
if(hstmt) { if(hstmt) {
ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len); ret = SQLExecDirect(hstmt, (SQLCHAR *)tmpbuf, (SQLINTEGER)len);
if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){ if(ret != SQL_SUCCESS && ret != SQL_SUCCESS_WITH_INFO){
sqlerr(tmpbuf); sqlerr((char *)tmpbuf);
return; return;
} }
attempt = 0; attempt = 0;

View File

@ -216,12 +216,12 @@ int ceparseargs(const char *str){
#endif #endif
void parsehost(int family, char *host, struct sockaddr *sa){ void parsehost(int family, unsigned char *host, struct sockaddr *sa){
char *sp=NULL,*se=NULL; char *sp=NULL,*se=NULL;
unsigned short port; unsigned short port;
if(*host == '[') se=strchr(host, ']'); if(*host == '[') se=strchr((char *)host, ']');
if ( (sp = strchr(se?se:host, ':')) ) *sp = 0; if ( (sp = strchr(se?se:(char *)host, ':')) ) *sp = 0;
if(se){ if(se){
*se = 0; *se = 0;
} }
@ -297,7 +297,7 @@ int parseconnusername(char *username, struct clientparam *param, int extpasswd,
if(!username || !*username) return 1; if(!username || !*username) return 1;
if ((sb=strchr(username, conf.delimchar)) == NULL){ if ((sb=strchr(username, conf.delimchar)) == NULL){
if(!param->hostname && param->remsock == INVALID_SOCKET) return 2; if(!param->hostname && param->remsock == INVALID_SOCKET) return 2;
if(param->hostname)parsehostname(param->hostname, param, port); if(param->hostname)parsehostname((char *)param->hostname, param, port);
return parseusername(username, param, extpasswd); return parseusername(username, param, extpasswd);
} }
while ((se=strchr(sb+1, conf.delimchar)))sb=se; while ((se=strchr(sb+1, conf.delimchar)))sb=se;
@ -466,7 +466,7 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
break; break;
case 'N': case 'N':
if(param->service >=0 && param->service < 15) { if(param->service < 15) {
len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0; len = (conf.stringtable)? (int)strlen((char *)conf.stringtable[SERVICES + param->service]) : 0;
if(len > 20) len = 20; if(len > 20) len = 20;
memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1); memcpy(buf+i, (len)?conf.stringtable[SERVICES + param->service]:(unsigned char*)"-", (len)?len:1);
@ -648,14 +648,14 @@ int doconnect(struct clientparam * param){
} }
if(!*SAPORT(&param->sinsr))*SAPORT(&param->sinsr) = *SAPORT(&param->req); if(!*SAPORT(&param->sinsr))*SAPORT(&param->sinsr) = *SAPORT(&param->req);
if ((param->remsock=so._socket(SASOCK(&param->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);} if ((param->remsock=so._socket(SASOCK(&param->sinsr), SOCK_STREAM, IPPROTO_TCP)) == INVALID_SOCKET) {return (11);}
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg)); so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
#ifdef REUSE #ifdef REUSE
{ {
int opt; int opt;
#ifdef SO_REUSEADDR #ifdef SO_REUSEADDR
opt = 1; opt = 1;
so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int)); so._setsockopt(param->remsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
#endif #endif
#ifdef SO_REUSEPORT #ifdef SO_REUSEPORT
opt = 1; opt = 1;

View File

@ -735,7 +735,7 @@ static int h_nolog(int argc, unsigned char **argv){
return(1); return(1);
} }
while(acl->next) acl = acl->next; while(acl->next) acl = acl->next;
if(!strcmp(argv[0],"nolog")) acl->nolog = 1; if(!strcmp((char *)argv[0],"nolog")) acl->nolog = 1;
else acl->weight = atoi((char*)argv[1]); else acl->weight = atoi((char*)argv[1]);
return 0; return 0;
} }
@ -748,14 +748,14 @@ int scanipl(unsigned char *arg, struct iplist *dst){
#endif #endif
char * slash, *dash; char * slash, *dash;
int masklen, addrlen; int masklen, addrlen;
if((slash = strchr(arg, '/'))) *slash = 0; if((slash = strchr((char *)arg, '/'))) *slash = 0;
if((dash = strchr(arg,'-'))) *dash = 0; if((dash = strchr((char *)arg,'-'))) *dash = 0;
if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1; if(!getip46(46, arg, (struct sockaddr *)&sa)) return 1;
memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa)); memcpy(&dst->ip_from, SAADDR(&sa), SAADDRLEN(&sa));
dst->family = *SAFAMILY(&sa); dst->family = *SAFAMILY(&sa);
if(dash){ if(dash){
if(!getip46(46, dash+1, (struct sockaddr *)&sa)) return 2; if(!getip46(46, (unsigned char *)dash+1, (struct sockaddr *)&sa)) return 2;
memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa)); memcpy(&dst->ip_to, SAADDR(&sa), SAADDRLEN(&sa));
if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3; if(*SAFAMILY(&sa) != dst->family || memcmp(&dst->ip_to, &dst->ip_from, SAADDRLEN(&sa)) < 0) return 3;
return 0; return 0;
@ -1262,7 +1262,7 @@ static int h_plugin(int argc, unsigned char **argv){
#ifdef _WINCE #ifdef _WINCE
hi = LoadLibraryW((LPCWSTR)CEToUnicode(argv[1])); hi = LoadLibraryW((LPCWSTR)CEToUnicode(argv[1]));
#else #else
hi = LoadLibrary(argv[1]); hi = LoadLibrary((char *)argv[1]);
#endif #endif
if(!hi) { if(!hi) {
fprintf(stderr, "Failed to load %s, code %d\n", argv[1], (int)GetLastError()); fprintf(stderr, "Failed to load %s, code %d\n", argv[1], (int)GetLastError());
@ -1271,7 +1271,7 @@ static int h_plugin(int argc, unsigned char **argv){
#ifdef _WINCE #ifdef _WINCE
fp = GetProcAddressW(hi, (LPCWSTR)CEToUnicode(argv[2])); fp = GetProcAddressW(hi, (LPCWSTR)CEToUnicode(argv[2]));
#else #else
fp = GetProcAddress(hi, argv[2]); fp = GetProcAddress(hi, (char *)argv[2]);
#endif #endif
if(!fp) { if(!fp) {
printf("%s not found in %s, code: %d\n", argv[2], argv[1], (int)GetLastError()); printf("%s not found in %s, code: %d\n", argv[2], argv[1], (int)GetLastError());

View File

@ -19,7 +19,7 @@ int sockgetchar(SOCKET sock, int timeosec, int timeousec){
FD_ZERO(&fds); FD_ZERO(&fds);
FD_SET(sock, &fds); FD_SET(sock, &fds);
if (select (((int)sock)+1, &fds, NULL, NULL, &tv)!=1) return EOF; if (select (((int)sock)+1, &fds, NULL, NULL, &tv)!=1) return EOF;
if (recv(sock, &buf, 1, 0)!=1) return EOF; if (recv(sock, (char *)&buf, 1, 0)!=1) return EOF;
return((int)buf); return((int)buf);
} }
@ -95,7 +95,7 @@ int main(int argc, char *argv[]){
fprintf(stderr, "Unable to connect: %s\n", host); fprintf(stderr, "Unable to connect: %s\n", host);
return 8; return 8;
} }
if(send(sock, buf, (int)strlen((char *)buf), 0) != (int)strlen((char *)buf)) return 9; if(send(sock, (char *)buf, (int)strlen((char *)buf), 0) != (int)strlen((char *)buf)) return 9;
while( (i = sockgetline(sock, buf, sizeof(buf) - 1, '\n', 30)) > 2); while( (i = sockgetline(sock, buf, sizeof(buf) - 1, '\n', 30)) > 2);
if(i<1) return 9; if(i<1) return 9;
if(!(fp = fopen(argv[argc-1], "w"))) { if(!(fp = fopen(argv[argc-1], "w"))) {

View File

@ -39,7 +39,7 @@ void * dnsprchild(struct clientparam* param) {
} }
buf = bbuf+2; buf = bbuf+2;
size = sizeof(param->sincr); size = sizeof(param->sincr);
i = so._recvfrom(param->srv->srvsock, buf, BUFSIZE, 0, (struct sockaddr *)&param->sincr, &size); i = so._recvfrom(param->srv->srvsock, (char *)buf, BUFSIZE, 0, (struct sockaddr *)&param->sincr, &size);
size = sizeof(param->sinsl); size = sizeof(param->sinsl);
getsockname(param->srv->srvsock, (struct sockaddr *)&param->sincl, &size); getsockname(param->srv->srvsock, (struct sockaddr *)&param->sincl, &size);
#ifdef _WIN32 #ifdef _WIN32
@ -47,7 +47,7 @@ void * dnsprchild(struct clientparam* param) {
RETURN(818); RETURN(818);
} }
ioctlsocket(param->clisock, FIONBIO, &ul); ioctlsocket(param->clisock, FIONBIO, &ul);
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);}; if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (char *)&ul, sizeof(int))) {RETURN(820);};
if(so._bind(param->clisock,(struct sockaddr *)&param->sincl,SASIZE(&param->sincl))) { if(so._bind(param->clisock,(struct sockaddr *)&param->sincl,SASIZE(&param->sincl))) {
RETURN(822); RETURN(822);
} }
@ -195,8 +195,8 @@ CLEANRET:
sprintf((char *)buf, "%04x/%s/", sprintf((char *)buf, "%04x/%s/",
(unsigned)type, (unsigned)type,
host?host:""); host?host:"");
if(ip && type == 0x01 || type == 0x1c){ if((ip && type == 0x01) || type == 0x1c){
myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, buf+strlen(buf), 64); myinet_ntop(type == 0x01? AF_INET:AF_INET6, addr, (char *)buf+strlen((char *)buf), 64);
} }
(*param->srv->logfunc)(param, buf); (*param->srv->logfunc)(param, buf);
} }

View File

@ -76,7 +76,7 @@ void * ftpprchild(struct clientparam* param) {
{ {
int action, reqbufsize, reqsize; int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE; reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1; reqsize = (int)strlen((char *)buf) + 1;
action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize); action = handlereqfilters(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){ if(action == HANDLED){
@ -94,7 +94,7 @@ void * ftpprchild(struct clientparam* param) {
{ {
int action, reqbufsize, reqsize; int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE; reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1; reqsize = (int)strlen((char *)buf) + 1;
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize); action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){ if(action == HANDLED){
@ -150,13 +150,13 @@ void * ftpprchild(struct clientparam* param) {
clidatasock = INVALID_SOCKET; clidatasock = INVALID_SOCKET;
RETURN(826); RETURN(826);
} }
sprintf(buf, "200 OK\r\n"); sprintf((char *)buf, "200 OK\r\n");
} }
#ifndef WITHMAIN #ifndef WITHMAIN
{ {
int action, reqbufsize, reqsize; int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE; reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1; reqsize = (int)strlen((char *)buf) + 1;
action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize); action = handlehdrfilterssrv(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){ if(action == HANDLED){
@ -184,7 +184,7 @@ void * ftpprchild(struct clientparam* param) {
{ {
int action, reqbufsize, reqsize; int action, reqbufsize, reqsize;
reqbufsize = BUFSIZE; reqbufsize = BUFSIZE;
reqsize = (int)strlen(buf) + 1; reqsize = (int)strlen((char *)buf) + 1;
action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize); action = handlehdrfilterscli(param, &buf, &reqbufsize, 0, &reqsize);
if(action == HANDLED){ if(action == HANDLED){
@ -239,8 +239,8 @@ void * ftpprchild(struct clientparam* param) {
} }
sc = param->remsock; sc = param->remsock;
param->remsock = ss; param->remsock = ss;
so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg)); so._setsockopt(param->remsock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg)); so._setsockopt(clidatasock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
param->clisock = clidatasock; param->clisock = clidatasock;
res = sockmap(param, conf.timeouts[CONNECTION_S]); res = sockmap(param, conf.timeouts[CONNECTION_S]);
if(param->remsock != INVALID_SOCKET) { if(param->remsock != INVALID_SOCKET) {

View File

@ -128,11 +128,11 @@ static int searchcookie(struct clientparam *param, struct flap_header * flap, in
icq_cookie_mutex_init = 1; icq_cookie_mutex_init = 1;
} }
pthread_mutex_lock(&icq_cookie_mutex); pthread_mutex_lock(&icq_cookie_mutex);
for(ic = icq_cookies; ic; ic = ic->next)if(!strcmp(param->username, ic->id))break; for(ic = icq_cookies; ic; ic = ic->next)if(!strcmp((char *)param->username, ic->id))break;
if(!ic){ if(!ic){
ic = myalloc(sizeof(struct icq_cookie)); ic = myalloc(sizeof(struct icq_cookie));
memset(ic, 0, sizeof(struct icq_cookie)); memset(ic, 0, sizeof(struct icq_cookie));
ic->id = mystrdup(param->username); ic->id = mystrdup((char *)param->username);
ic->next = icq_cookies; ic->next = icq_cookies;
icq_cookies = ic; icq_cookies = ic;
} }
@ -202,10 +202,10 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
state->state = ONCHAN; state->state = ONCHAN;
} }
else { else {
if(!state->leftinstate)param->srv->logfunc(param, "Warning: need resync"); if(!state->leftinstate)param->srv->logfunc(param, (unsigned char *)"Warning: need resync");
state->leftinstate++; state->leftinstate++;
if(state->leftinstate > 65535){ if(state->leftinstate > 65535){
param->srv->logfunc(param, "Out of Sync"); param->srv->logfunc(param, (unsigned char *)"Out of Sync");
return REJECT; return REJECT;
} }
} }
@ -214,7 +214,7 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
break; break;
case ONCHAN: case ONCHAN:
if (*start >= 10){ if (*start >= 10){
param->srv->logfunc(param, "Warning: Wrong channel"); param->srv->logfunc(param, (unsigned char *)"Warning: Wrong channel");
state->state = ONBEGIN; state->state = ONBEGIN;
} }
else { else {
@ -234,15 +234,15 @@ static FILTER_ACTION icq_srv(void *fc, struct clientparam * param, unsigned char
case ONSEQ2: case ONSEQ2:
state->gotseq += *start; state->gotseq += *start;
if(state->gotseq != state->srvseq){ if(state->gotseq != state->srvseq){
char smallbuf[64]; unsigned char smallbuf[64];
if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){ if(((state->gotseq < state->srvseq) || ((state->gotseq - state->srvseq) > 10 )) && (!state->resyncseq || state->gotseq != state->resyncseq)){
sprintf(smallbuf, "Warning: Wrong sequence, expected: %04hx got: %04hx", state->srvseq, state->gotseq); sprintf((char *)smallbuf, "Warning: Wrong sequence, expected: %04hx got: %04hx", state->srvseq, state->gotseq);
param->srv->logfunc(param, smallbuf); param->srv->logfunc(param, smallbuf);
state->state = ONBEGIN; state->state = ONBEGIN;
state->resyncseq = state->gotseq; state->resyncseq = state->gotseq;
break; break;
} }
sprintf(smallbuf, "Warning: %hu flaps are lost on resync", state->gotseq - state->srvseq ); sprintf((char *)smallbuf, "Warning: %d flaps are lost on resync", state->gotseq - state->srvseq );
param->srv->logfunc(param, smallbuf); param->srv->logfunc(param, smallbuf);
state->srvseq = state->gotseq; state->srvseq = state->gotseq;
*(start-1) = (state->seq>>8); *(start-1) = (state->seq>>8);
@ -339,7 +339,7 @@ static int readflap(struct clientparam * param, int direction, unsigned char *bu
if(flap->id != 0x2a) return 2; if(flap->id != 0x2a) return 2;
len = ntohs(flap->size); len = ntohs(flap->size);
if(len > buflen-6) return 3; if(len > buflen-6) return 3;
i = sockgetlinebuf(param, direction, flap->data, len, EOF, conf.timeouts[STRING_S]); i = sockgetlinebuf(param, direction, (unsigned char *)flap->data, len, EOF, conf.timeouts[STRING_S]);
if(len != i) return 4; if(len != i) return 4;
return 0; return 0;
@ -418,7 +418,7 @@ void * icqprchild(struct clientparam* param) {
for(ic = icq_cookies; ic; ic=ic->next){ for(ic = icq_cookies; ic; ic=ic->next){
if(ic->size && ic->size == tlv->size && !memcmp(ic->cookie, tlv->data, ntohs(tlv->size))){ if(ic->size && ic->size == tlv->size && !memcmp(ic->cookie, tlv->data, ntohs(tlv->size))){
parsehostname((char *)ic->connectstring, param, ntohs(param->srv->targetport)); parsehostname((char *)ic->connectstring, param, ntohs(param->srv->targetport));
if(!param->username && ic->id) param->username = mystrdup(ic->id); if(!param->username && ic->id) param->username = (unsigned char *)mystrdup(ic->id);
break; break;
} }
} }

View File

@ -144,7 +144,7 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
if(!pcrefd->re) return pcrefd->action; if(!pcrefd->re) return pcrefd->action;
for(; offset < *length_p; nreplaces++){ for(; offset < *length_p; nreplaces++){
count = pcre_exec(pcrefd->re, NULL, *buf_p, *length_p, offset, 0, ovector, 48); count = pcre_exec(pcrefd->re, NULL, (char *)*buf_p, *length_p, offset, 0, ovector, 48);
if(count <= 0) break; if(count <= 0) break;
if(!(replace = pcrefd->replace) || param->nooverwritefilter) return pcrefd->action; if(!(replace = pcrefd->replace) || param->nooverwritefilter) return pcrefd->action;
@ -195,7 +195,7 @@ static FILTER_ACTION pcre_filter_buffer(void *fc, struct clientparam *param, uns
} }
memcpy(newbuf, *buf_p, ovector[0]); memcpy(newbuf, *buf_p, ovector[0]);
(*pl->myfree)(*buf_p); (*pl->myfree)(*buf_p);
*buf_p = newbuf; *buf_p = (unsigned char *)newbuf;
*bufsize_p = ovector[0] + replen + 1; *bufsize_p = ovector[0] + replen + 1;
} }
memcpy(*buf_p + ovector[0], tmpbuf, replen); memcpy(*buf_p + ovector[0], tmpbuf, replen);
@ -229,15 +229,15 @@ static int h_pcre(int argc, unsigned char **argv){
struct filter *newf; struct filter *newf;
char *replace = NULL; char *replace = NULL;
if(!strncmp(argv[2], "allow",5)) action = PASS; if(!strncmp((char *)argv[2], "allow",5)) action = PASS;
else if(!strncmp(argv[2], "deny",4)) action = REJECT; else if(!strncmp((char *)argv[2], "deny",4)) action = REJECT;
else if(!strncmp(argv[2], "remove",6)) action = REMOVE; else if(!strncmp((char *)argv[2], "remove",6)) action = REMOVE;
else if(!strncmp(argv[2], "dunno",5)) action = CONTINUE; else if(!strncmp((char *)argv[2], "dunno",5)) action = CONTINUE;
else return 1; else return 1;
if(!strncmp(argv[0], "pcre_rewrite", 12)) { if(!strncmp((char *)argv[0], "pcre_rewrite", 12)) {
int i,j; int i,j;
offset = 5; offset = 5;
replace = pl->mystrdup(argv[4]); replace = pl->mystrdup((char *)argv[4]);
if(!replace) return 9; if(!replace) return 9;
for(i=0, j=0; replace[i]; i++, j++){ for(i=0, j=0; replace[i]; i++, j++){
if(replace[i] == '\\'){ if(replace[i] == '\\'){
@ -266,7 +266,7 @@ static int h_pcre(int argc, unsigned char **argv){
replace[j] = 0; replace[j] = 0;
} }
if(!(acl = pl->make_ace(argc - offset, argv + offset))) return 2; if(!(acl = pl->make_ace(argc - offset, argv + offset))) return 2;
acl->nolog = (strstr(argv[2],"log") == 0); acl->nolog = (strstr((char *)argv[2],"log") == 0);
if(*argv[3] && !(*argv[3] == '*' && !argv[3][1]) ){ if(*argv[3] && !(*argv[3] == '*' && !argv[3][1]) ){
re = pcre_compile((char *)argv[3], pcre_options, &errptr, &offset, NULL); re = pcre_compile((char *)argv[3], pcre_options, &errptr, &offset, NULL);
if(!re) { if(!re) {
@ -296,11 +296,11 @@ static int h_pcre(int argc, unsigned char **argv){
newf->data = flt; newf->data = flt;
newf->filter_open = pcre_filter_open; newf->filter_open = pcre_filter_open;
newf->filter_client = pcre_filter_client; newf->filter_client = pcre_filter_client;
if(strstr(argv[1], "request"))newf->filter_request = pcre_filter_buffer; if(strstr((char *)argv[1], "request"))newf->filter_request = pcre_filter_buffer;
if(strstr(argv[1], "cliheader"))newf->filter_header_cli = pcre_filter_buffer; if(strstr((char *)argv[1], "cliheader"))newf->filter_header_cli = pcre_filter_buffer;
if(strstr(argv[1], "clidata"))newf->filter_data_cli = pcre_filter_buffer; if(strstr((char *)argv[1], "clidata"))newf->filter_data_cli = pcre_filter_buffer;
if(strstr(argv[1], "srvheader"))newf->filter_header_srv = pcre_filter_buffer; if(strstr((char *)argv[1], "srvheader"))newf->filter_header_srv = pcre_filter_buffer;
if(strstr(argv[1], "srvdata"))newf->filter_data_srv = pcre_filter_buffer; if(strstr((char *)argv[1], "srvdata"))newf->filter_data_srv = pcre_filter_buffer;
newf->filter_clear = pcre_filter_clear; newf->filter_clear = pcre_filter_clear;
newf->filter_close = pcre_filter_close; newf->filter_close = pcre_filter_close;
@ -334,7 +334,7 @@ static int h_pcre_options(int argc, unsigned char **argv){
pcre_options = 0; pcre_options = 0;
for(j=1; j<argc; j++) for(j=1; j<argc; j++)
for(i=0; pcreopts[i].name; i++) for(i=0; pcreopts[i].name; i++)
if(!strcmp(pcreopts[i].name, argv[j])) if(!strcmp(pcreopts[i].name, (char *)argv[j]))
pcre_options |= pcreopts[i].value; pcre_options |= pcreopts[i].value;
return 0; return 0;

View File

@ -41,7 +41,7 @@ extern "C" {
if(dom)*dom++=0; if(dom)*dom++=0;
if(!LogonUser( dom?dom:(char *)param->username, if(!LogonUser( dom?dom:(char *)param->username,
dom?(char *)param->username:NULL, dom?(char *)param->username:NULL,
param->password, (char *)param->password,
LOGON32_LOGON_NETWORK, LOGON32_LOGON_NETWORK,
LOGON32_PROVIDER_DEFAULT, LOGON32_PROVIDER_DEFAULT,
&h))return 5; &h))return 5;
@ -54,7 +54,7 @@ extern "C" {
if(GetLengthSid(ptg->Groups[i].Sid)==sidlen){ if(GetLengthSid(ptg->Groups[i].Sid)==sidlen){
if(!memcmp((void *)ptg->Groups[i].Sid, (void *)psid, sidlen)) { if(!memcmp((void *)ptg->Groups[i].Sid, (void *)psid, sidlen)) {
setlocale(LC_CTYPE, ".ACP"); setlocale(LC_CTYPE, ".ACP");
_strlwr(param->username); _strlwr((char *)param->username);
return 0; return 0;
} }
} }

View File

@ -26,7 +26,7 @@ extern "C" {
#endif #endif
unsigned char * conv_utf8_to_cp1251(unsigned char *s){ unsigned char * conv_utf8_to_cp1251(unsigned char *s){
int i, j=0, n=(int)strlen(s); int i, j=0, n=(int)strlen((char *)s);
int byte2 = 0; int byte2 = 0;
int c1, new_c1, new_c2, new_i; int c1, new_c1, new_c2, new_i;
for(i = 0; i < n; i++){ for(i = 0; i < n; i++){

View File

@ -328,7 +328,7 @@ for(;;){
prefix = (int)(se - buf); prefix = (int)(se - buf);
su = (unsigned char*)strrchr((char *)sb, '@'); su = (unsigned char*)strrchr((char *)sb, '@');
if(su) { if(su) {
su = mystrdup(sb); su = (unsigned char *)mystrdup((char *)sb);
decodeurl(su, 0); decodeurl(su, 0);
parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80)); parseconnusername((char *)su, (struct clientparam *)param, 1, (unsigned short)((ftp)?21:80));
myfree(su); myfree(su);
@ -490,7 +490,7 @@ for(;;){
if(!sb)continue; if(!sb)continue;
++sb; ++sb;
while(isspace(*sb))sb++; while(isspace(*sb))sb++;
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64); sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u",&contentlength64);
if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){ if(param->maxtrafout64 && (param->maxtrafout64 < param->statscli64 || contentlength64 > param->maxtrafout64 - param->statscli64)){
RETURN(10); RETURN(10);
} }
@ -510,7 +510,7 @@ for(;;){
buf[inbuf] = 0; buf[inbuf] = 0;
reqsize = (int)strlen(req); reqsize = (int)strlen((char *)req);
reqbufsize = reqsize + 1; reqbufsize = reqsize + 1;
#ifndef WITHMAIN #ifndef WITHMAIN
@ -529,7 +529,7 @@ for(;;){
uint64_t newlen64; uint64_t newlen64;
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S); newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
if(newlen64 == contentlength64) { if(newlen64 == contentlength64) {
action = handledatfltcli(param, &param->clibuf, &param->clibufsize, 0, &param->cliinbuf); action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, 0, (int *)&param->cliinbuf);
if(action == HANDLED){ if(action == HANDLED){
RETURN(0); RETURN(0);
} }
@ -803,7 +803,8 @@ for(;;){
else { else {
redirect = 1; redirect = 1;
if(socksend(param->remsock, req , (res = (int)strlen((char *)req)), conf.timeouts[STRING_L]) != res) { res = (int)strlen((char *)req);
if(socksend(param->remsock, req , res, conf.timeouts[STRING_L]) != res) {
RETURN(518); RETURN(518);
} }
param->statscli64 += res; param->statscli64 += res;
@ -893,7 +894,7 @@ for(;;){
if(!sb)continue; if(!sb)continue;
++sb; ++sb;
while(isspace(*sb))sb++; while(isspace(*sb))sb++;
sscanf(sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64); sscanf((char *)sb, "%"PRINTF_INT64_MODIFIER"u", &contentlength64);
hascontent = 1; hascontent = 1;
if(param->unsafefilter && param->ndatfilterssrv > 0) { if(param->unsafefilter && param->ndatfilterssrv > 0) {
hascontent = 2; hascontent = 2;
@ -909,7 +910,7 @@ for(;;){
if(!sb)continue; if(!sb)continue;
++sb; ++sb;
while(isspace(*sb))sb++; while(isspace(*sb))sb++;
if(!strncasecmp(sb, "chunked", 7)){ if(!strncasecmp((char *)sb, "chunked", 7)){
param->chunked = 1; param->chunked = 1;
} }
} }
@ -959,7 +960,7 @@ for(;;){
uint64_t newlen; uint64_t newlen;
newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S); newlen = (uint64_t)sockfillbuffsrv(param, (unsigned long) contentlength64, CONNECTION_S);
if(newlen == contentlength64) { if(newlen == contentlength64) {
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, 0, &param->srvinbuf); action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, 0, (int *)&param->srvinbuf);
param->nolongdatfilter = 1; param->nolongdatfilter = 1;
if(action == HANDLED){ if(action == HANDLED){
RETURN(0); RETURN(0);
@ -992,7 +993,7 @@ for(;;){
if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) { if((param->chunked || contentlength64 > 0) && param->operation != HTTP_HEAD && res != 204 && res != 304) {
do { do {
if(param->chunked){ if(param->chunked){
char smallbuf[32]; unsigned char smallbuf[32];
while ((i = sockgetlinebuf(param, SERVER, smallbuf, 30, '\n', conf.timeouts[STRING_S])) == 2) { while ((i = sockgetlinebuf(param, SERVER, smallbuf, 30, '\n', conf.timeouts[STRING_S])) == 2) {
if (socksend(param->clisock, smallbuf, i, conf.timeouts[STRING_S]) != i){ if (socksend(param->clisock, smallbuf, i, conf.timeouts[STRING_S]) != i){
RETURN(533); RETURN(533);
@ -1015,7 +1016,7 @@ for(;;){
} }
smallbuf[i] = 0; smallbuf[i] = 0;
contentlength64 = 0; contentlength64 = 0;
sscanf(smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64); sscanf((char *)smallbuf, "%"PRINTF_INT64_MODIFIER"x", &contentlength64);
if(contentlength64 == 0) { if(contentlength64 == 0) {
param->chunked = 2; param->chunked = 2;
} }
@ -1048,7 +1049,7 @@ REQUESTEND:
RETURN(0); RETURN(0);
} }
if(param->transparent && (!ckeepalive || !keepalive)) {RETURN (0);} if(param->transparent && (!ckeepalive || !keepalive)) {RETURN (0);}
logurl(param, buf, (char *)req, ftp); logurl(param, (char *)buf, (char *)req, ftp);
param->status = 0; param->status = 0;
} }
@ -1095,7 +1096,7 @@ CLEANRET:
socksend(param->clisock, (unsigned char *)proxy_stringtable[0], (int)strlen(proxy_stringtable[0]), conf.timeouts[STRING_S]); socksend(param->clisock, (unsigned char *)proxy_stringtable[0], (int)strlen(proxy_stringtable[0]), conf.timeouts[STRING_S]);
} }
} }
logurl(param, buf, (char *)req, ftp); logurl(param, (char *)buf, (char *)req, ftp);
if(req)myfree(req); if(req)myfree(req);
if(buf)myfree(buf); if(buf)myfree(buf);
if(ftpbase)myfree(ftpbase); if(ftpbase)myfree(ftpbase);

View File

@ -233,7 +233,7 @@ void mschap(const unsigned char *win_password,
struct hashtable; struct hashtable;
void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires); void hashadd(struct hashtable *ht, const unsigned char* name, unsigned char* value, time_t expires);
void parsehost(int family, char *host, struct sockaddr *sa); void parsehost(int family, unsigned char *host, struct sockaddr *sa);
int parsehostname(char *hostname, struct clientparam *param, unsigned short port); int parsehostname(char *hostname, struct clientparam *param, unsigned short port);
int parseusername(char *username, struct clientparam *param, int extpasswd); int parseusername(char *username, struct clientparam *param, int extpasswd);
int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port); int parseconnusername(char *username, struct clientparam *param, int extpasswd, unsigned short port);

View File

@ -24,21 +24,21 @@ void * threadfunc (void *p) {
param->remsock = so._accept(param->srv->cbsock, (struct sockaddr*)&param->sinsr, &size); param->remsock = so._accept(param->srv->cbsock, (struct sockaddr*)&param->sinsr, &size);
if(param->remsock == INVALID_SOCKET) { if(param->remsock == INVALID_SOCKET) {
param->res = 13; param->res = 13;
param->srv->logfunc(param, "Connect back accept() failed"); param->srv->logfunc(param, (unsigned char *)"Connect back accept() failed");
continue; continue;
} }
#ifndef WITHMAIN #ifndef WITHMAIN
param->req = param->sinsr; param->req = param->sinsr;
if(param->srv->acl) param->res = checkACL(param); if(param->srv->acl) param->res = checkACL(param);
if(param->res){ if(param->res){
param->srv->logfunc(param, "Connect back ACL failed"); param->srv->logfunc(param, (unsigned char *)"Connect back ACL failed");
so._closesocket(param->remsock); so._closesocket(param->remsock);
param->remsock = INVALID_SOCKET; param->remsock = INVALID_SOCKET;
continue; continue;
} }
#endif #endif
if(so._sendto(param->remsock, "C", 1, 0, (struct sockaddr*)&param->sinsr, size) != 1){ if(so._sendto(param->remsock, "C", 1, 0, (struct sockaddr*)&param->sinsr, size) != 1){
param->srv->logfunc(param, "Connect back sending command failed"); param->srv->logfunc(param, (unsigned char *)"Connect back sending command failed");
so._closesocket(param->remsock); so._closesocket(param->remsock);
param->remsock = INVALID_SOCKET; param->remsock = INVALID_SOCKET;
continue; continue;
@ -214,7 +214,7 @@ int MODULEMAINFUNC (int argc, char** argv){
case 'l': case 'l':
srv.logfunc = logstdout; srv.logfunc = logstdout;
if(srv.logtarget) myfree(srv.logtarget); if(srv.logtarget) myfree(srv.logtarget);
srv.logtarget = mystrdup((unsigned char*)argv[i] + 2); srv.logtarget = (unsigned char *)mystrdup(argv[i] + 2);
if(argv[i][2]) { if(argv[i][2]) {
if(argv[i][2]=='@'){ if(argv[i][2]=='@'){
@ -237,7 +237,7 @@ int MODULEMAINFUNC (int argc, char** argv){
} }
break; break;
case 'i': case 'i':
getip46(46, argv[i]+2, (struct sockaddr *)&srv.intsa); getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.intsa);
break; break;
case 'e': case 'e':
{ {
@ -250,7 +250,7 @@ int MODULEMAINFUNC (int argc, char** argv){
else srv.extsa6 = sa6; else srv.extsa6 = sa6;
} }
#else #else
error = !getip46(46, argv[i]+2, (struct sockaddr *)&srv.extsa); error = !getip46(46, (unsigned char *)argv[i]+2, (struct sockaddr *)&srv.extsa);
#endif #endif
} }
break; break;
@ -280,7 +280,7 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif #endif
case 'f': case 'f':
if(srv.logformat)myfree(srv.logformat); if(srv.logformat)myfree(srv.logformat);
srv.logformat = mystrdup((unsigned char *)argv[i] + 2); srv.logformat = (unsigned char *)mystrdup(argv[i] + 2);
break; break;
case 't': case 't':
srv.silent = 1; srv.silent = 1;
@ -289,11 +289,11 @@ int MODULEMAINFUNC (int argc, char** argv){
hostname = argv[i] + 2; hostname = argv[i] + 2;
break; break;
case 'r': case 'r':
cbc_string = mystrdup(argv[i] + 2); cbc_string = (unsigned char *)mystrdup(argv[i] + 2);
iscbc = 1; iscbc = 1;
break; break;
case 'R': case 'R':
cbl_string = mystrdup(argv[i] + 2); cbl_string = (unsigned char *)mystrdup(argv[i] + 2);
iscbl = 1; iscbl = 1;
break; break;
case 'u': case 'u':
@ -452,10 +452,10 @@ int MODULEMAINFUNC (int argc, char** argv){
#endif #endif
srv.srvsock = sock; srv.srvsock = sock;
opt = 1; opt = 1;
if(so._setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int)))perror("setsockopt()"); if(so._setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int)))perror("setsockopt()");
#ifdef SO_REUSEPORT #ifdef SO_REUSEPORT
opt = 1; opt = 1;
so._setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int)); so._setsockopt(sock, SOL_SOCKET, SO_REUSEPORT, (char *)&opt, sizeof(int));
#endif #endif
} }
size = sizeof(srv.intsa); size = sizeof(srv.intsa);
@ -486,22 +486,22 @@ int MODULEMAINFUNC (int argc, char** argv){
if(iscbl){ if(iscbl){
parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa); parsehost(srv.family, cbl_string, (struct sockaddr *)&cbsa);
if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) { if((srv.cbsock=so._socket(SASOCK(&cbsa), SOCK_STREAM, IPPROTO_TCP))==INVALID_SOCKET) {
(*srv.logfunc)(&defparam, "Failed to allocate connect back socket"); (*srv.logfunc)(&defparam, (unsigned char *)"Failed to allocate connect back socket");
return -6; return -6;
} }
opt = 1; opt = 1;
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&opt, sizeof(int)); so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEADDR, (char *)&opt, sizeof(int));
#ifdef SO_REUSEPORT #ifdef SO_REUSEPORT
opt = 1; opt = 1;
so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEPORT, (unsigned char *)&opt, sizeof(int)); so._setsockopt(srv.cbsock, SOL_SOCKET, SO_REUSEPORT, (char *)&opt, sizeof(int));
#endif #endif
if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) { if(so._bind(srv.cbsock, (struct sockaddr*)&cbsa, SASIZE(&cbsa))==-1) {
(*srv.logfunc)(&defparam, "Failed to bind connect back socket"); (*srv.logfunc)(&defparam, (unsigned char *)"Failed to bind connect back socket");
return -7; return -7;
} }
if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) { if(so._listen(srv.cbsock, 1 + (srv.maxchild>>4))==-1) {
(*srv.logfunc)(&defparam, "Failed to listen connect back socket"); (*srv.logfunc)(&defparam, (unsigned char *)"Failed to listen connect back socket");
return -8; return -8;
} }
} }
@ -552,7 +552,7 @@ int MODULEMAINFUNC (int argc, char** argv){
usleep(SLEEPTIME); usleep(SLEEPTIME);
continue; continue;
} }
if(so._recvfrom(new_sock,buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) { if(so._recvfrom(new_sock,(char *)buf,1,0,(struct sockaddr*)&defparam.sincr, &size) != 1) {
so._closesocket(new_sock); so._closesocket(new_sock);
new_sock = INVALID_SOCKET; new_sock = INVALID_SOCKET;
usleep(SLEEPTIME); usleep(SLEEPTIME);
@ -622,8 +622,8 @@ int MODULEMAINFUNC (int argc, char** argv){
#else #else
fcntl(new_sock,F_SETFL,O_NONBLOCK); fcntl(new_sock,F_SETFL,O_NONBLOCK);
#endif #endif
so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (unsigned char *)&lg, sizeof(lg)); so._setsockopt(new_sock, SOL_SOCKET, SO_LINGER, (char *)&lg, sizeof(lg));
so._setsockopt(new_sock, SOL_SOCKET, SO_OOBINLINE, (unsigned char *)&opt, sizeof(int)); so._setsockopt(new_sock, SOL_SOCKET, SO_OOBINLINE, (char *)&opt, sizeof(int));
} }
else { else {
srv.fds.events = 0; srv.fds.events = 0;
@ -636,7 +636,7 @@ int MODULEMAINFUNC (int argc, char** argv){
continue; continue;
}; };
*newparam = defparam; *newparam = defparam;
if(defparam.hostname)newparam->hostname=strdup(defparam.hostname); if(defparam.hostname)newparam->hostname=(unsigned char *)strdup((char *)defparam.hostname);
clearstat(newparam); clearstat(newparam);
if(!isudp) newparam->clisock = new_sock; if(!isudp) newparam->clisock = new_sock;
#ifndef STDMAIN #ifndef STDMAIN
@ -716,7 +716,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
srv->version = conf.paused; srv->version = conf.paused;
srv->logfunc = conf.logfunc; srv->logfunc = conf.logfunc;
if(srv->logformat)myfree(srv->logformat); if(srv->logformat)myfree(srv->logformat);
srv->logformat = conf.logformat? mystrdup(conf.logformat) : NULL; srv->logformat = conf.logformat? (unsigned char *)mystrdup((char *)conf.logformat) : NULL;
srv->authfunc = conf.authfunc; srv->authfunc = conf.authfunc;
srv->usentlm = 0; srv->usentlm = 0;
srv->maxchild = conf.maxchild; srv->maxchild = conf.maxchild;
@ -724,7 +724,7 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
srv->time_start = time(NULL); srv->time_start = time(NULL);
if(conf.logtarget){ if(conf.logtarget){
if(srv->logtarget) myfree(srv->logtarget); if(srv->logtarget) myfree(srv->logtarget);
srv->logtarget = mystrdup(conf.logtarget); srv->logtarget = (unsigned char *)mystrdup((char *)conf.logtarget);
} }
srv->srvsock = INVALID_SOCKET; srv->srvsock = INVALID_SOCKET;
srv->logdumpsrv = conf.logdumpsrv; srv->logdumpsrv = conf.logdumpsrv;
@ -747,7 +747,7 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
if(srv->logformat){ if(srv->logformat){
char *s; char *s;
if(*srv->logformat == '-' && (s = strchr((char *)srv->logformat + 1, '+')) && s[1]){ if(*srv->logformat == '-' && (s = strchr((char *)srv->logformat + 1, '+')) && s[1]){
char* logformat = srv->logformat; unsigned char* logformat = srv->logformat;
*s = 0; *s = 0;
srv->nonprintable = (unsigned char *)mystrdup((char *)srv->logformat + 1); srv->nonprintable = (unsigned char *)mystrdup((char *)srv->logformat + 1);

View File

@ -37,7 +37,7 @@ int readreply (struct clientparam* param) {
return 0; return 0;
} }
buf[i] = 0; buf[i] = 0;
res = atoi(buf); res = atoi((char *)buf);
myfree(buf); myfree(buf);
return res; return res;
} }
@ -51,7 +51,7 @@ int readcommand (struct clientparam* param) {
i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L]);
if(i < 4) return 0; if(i < 4) return 0;
#ifndef WITHMAIN #ifndef WITHMAIN
if(!strncasecmp(buf, "MAIL", 4) || !strncasecmp(buf, "RCPT", 4) || !strncasecmp(buf, "STARTTLS", 8) || !strncasecmp(buf, "TURN", 4)){ if(!strncasecmp((char *)buf, "MAIL", 4) || !strncasecmp((char *)buf, "RCPT", 4) || !strncasecmp((char *)buf, "STARTTLS", 8) || !strncasecmp((char *)buf, "TURN", 4)){
res = handlehdrfilterscli(param, &buf, &bufsize, 0, &i); res = handlehdrfilterscli(param, &buf, &bufsize, 0, &i);
if(res != PASS) { if(res != PASS) {
myfree(buf); myfree(buf);
@ -62,7 +62,7 @@ int readcommand (struct clientparam* param) {
#endif #endif
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]); socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
myfree(buf); myfree(buf);
if(!strncasecmp(buf, "STARTTLS", 8) || !strncasecmp(buf, "TURN", 4)){ if(!strncasecmp((char *)buf, "STARTTLS", 8) || !strncasecmp((char *)buf, "TURN", 4)){
ret = 22; ret = 22;
} }
return ret; return ret;
@ -118,22 +118,22 @@ void * smtppchild(struct clientparam* param) {
else { else {
login = -1; login = -1;
buf[i] = 0; buf[i] = 0;
command = mystrdup(buf); command = mystrdup((char *)buf);
break; break;
} }
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]); i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
} }
if(!login) {RETURN(662);} if(!login) {RETURN(662);}
if(login == 1){ if(login == 1){
socksend(param->clisock, "334 VXNlcm5hbWU6\r\n", 18,conf.timeouts[STRING_S]); socksend(param->clisock, (unsigned char *)"334 VXNlcm5hbWU6\r\n", 18,conf.timeouts[STRING_S]);
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]); i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
if(i < 3) {RETURN(663);} if(i < 3) {RETURN(663);}
buf[i-2] = 0; buf[i-2] = 0;
i = de64(buf,username,255); i = de64(buf,username,255);
if(i < 1) {RETURN(664);} if(i < 1) {RETURN(664);}
username[i] = 0; username[i] = 0;
parseconnusername(username, param, 0, 25); parseconnusername((char *)username, param, 0, 25);
socksend(param->clisock, "334 UGFzc3dvcmQ6\r\n", 18,conf.timeouts[STRING_S]); socksend(param->clisock, (unsigned char *)"334 UGFzc3dvcmQ6\r\n", 18,conf.timeouts[STRING_S]);
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]); i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
if(i < 2) {RETURN(665);} if(i < 2) {RETURN(665);}
buf[i-2] = 0; buf[i-2] = 0;
@ -141,7 +141,7 @@ void * smtppchild(struct clientparam* param) {
if(i < 0) {RETURN(666);} if(i < 0) {RETURN(666);}
username[i] = 0; username[i] = 0;
if(param->extpassword) myfree(param->extpassword); if(param->extpassword) myfree(param->extpassword);
param->extpassword = mystrdup(username); param->extpassword = (unsigned char *)mystrdup((char *)username);
} }
else if(login == 2){ else if(login == 2){
if(i > 13) { if(i > 13) {
@ -149,7 +149,7 @@ void * smtppchild(struct clientparam* param) {
i = de64(buf+11,username,255); i = de64(buf+11,username,255);
} }
else { else {
socksend(param->clisock, "334\r\n", 5,conf.timeouts[STRING_S]); socksend(param->clisock, (unsigned char *)"334\r\n", 5,conf.timeouts[STRING_S]);
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]); i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
if(i < 3) {RETURN(667);} if(i < 3) {RETURN(667);}
buf[i-2] = 0; buf[i-2] = 0;
@ -157,18 +157,18 @@ void * smtppchild(struct clientparam* param) {
} }
if(i < 3 || *username) {RETURN(668);} if(i < 3 || *username) {RETURN(668);}
username[i] = 0; username[i] = 0;
parseconnusername(username+1, param, 0, 25); parseconnusername((char *)username+1, param, 0, 25);
res = (int)strlen(username+1) + 2; res = (int)strlen((char *)username+1) + 2;
if(res < i){ if(res < i){
if(param->extpassword) myfree(param->extpassword); if(param->extpassword) myfree(param->extpassword);
param->extpassword = mystrdup(username + res); param->extpassword = (unsigned char *)mystrdup((char *)username + res);
} }
} }
#ifndef WITHMAIN #ifndef WITHMAIN
{ {
int action, reqbufsize, reqsize; int action, reqbufsize, reqsize;
reqbufsize = reqsize = (int)strlen(param->hostname) + 1; reqbufsize = reqsize = (int)strlen((char *)param->hostname) + 1;
action = handlereqfilters(param, &param->hostname, &reqbufsize, 0, &reqsize); action = handlereqfilters(param, &param->hostname, &reqbufsize, 0, &reqsize);
if(action == HANDLED){ if(action == HANDLED){
RETURN(0); RETURN(0);
@ -186,9 +186,9 @@ void * smtppchild(struct clientparam* param) {
if( i < 3 ) {RETURN(671);} if( i < 3 ) {RETURN(671);}
buf[i] = 0; buf[i] = 0;
if(strncasecmp((char *)buf, "220", 3)||!strncasecmp((char *)buf+4, "PROXY", 5)){RETURN(672);} if(strncasecmp((char *)buf, "220", 3)||!strncasecmp((char *)buf+4, "PROXY", 5)){RETURN(672);}
i = sprintf(buf, "EHLO ["); i = sprintf((char *)buf, "EHLO [");
i += myinet_ntop(*SAFAMILY(&param->sinsl), SAADDR(&param->sinsl), buf+strlen(buf), 64); i += myinet_ntop(*SAFAMILY(&param->sinsl), SAADDR(&param->sinsl), (char *)buf+strlen((char *)buf), 64);
i += sprintf(buf+strlen(buf), "]\r\n"); i += sprintf((char *)buf+strlen((char *)buf), "]\r\n");
if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);} if(socksend(param->remsock, buf, i, conf.timeouts[STRING_S])!= i) {RETURN(673);}
param->statscli64+=i; param->statscli64+=i;
param->nwrites++; param->nwrites++;
@ -204,44 +204,44 @@ void * smtppchild(struct clientparam* param) {
if(i<3) {RETURN(672);} if(i<3) {RETURN(672);}
if(!command || (param->extusername && param->extpassword)){ if(!command || (param->extusername && param->extpassword)){
if(!param->extusername || !*param->extusername || !param->extpassword || !*param->extpassword || !login){ if(!param->extusername || !*param->extusername || !param->extpassword || !*param->extpassword || !login){
socksend(param->clisock, "235 auth required\r\n", 19,conf.timeouts[STRING_S]); socksend(param->clisock, (unsigned char *)"235 auth required\r\n", 19,conf.timeouts[STRING_S]);
} }
if ((login & 1)) { if ((login & 1)) {
socksend(param->remsock, "AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]); socksend(param->remsock, (unsigned char *)"AUTH LOGIN\r\n", 12, conf.timeouts[STRING_S]);
param->statscli64+=12; param->statscli64+=12;
param->nwrites++; param->nwrites++;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);} if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(680);}
en64(param->extusername, buf, (int)strlen(param->extusername)); en64(param->extusername, buf, (int)strlen((char *)param->extusername));
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]); socksend(param->remsock, buf, (int)strlen((char *)buf), conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
param->statscli64+=(i+2); param->statscli64+=(i+2);
param->nwrites+=2; param->nwrites+=2;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);} if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(681);}
en64(param->extpassword, buf, (int)strlen(param->extpassword)); en64(param->extpassword, buf, (int)strlen((char *)param->extpassword));
socksend(param->remsock, buf, (int)strlen(buf), conf.timeouts[STRING_S]); socksend(param->remsock, buf, (int)strlen((char *)buf), conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
param->statscli64+=(i+2); param->statscli64+=(i+2);
param->nwrites+=2; param->nwrites+=2;
} }
else if((login & 2)){ else if((login & 2)){
socksend(param->remsock, "AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]); socksend(param->remsock, (unsigned char *)"AUTH PLAIN\r\n", 12, conf.timeouts[STRING_S]);
param->statscli64+=(12); param->statscli64+=(12);
param->nwrites++; param->nwrites++;
i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]); i = sockgetlinebuf(param, SERVER, buf, sizeof(buf) - 1, '\n', conf.timeouts[STRING_L]);
if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);} if(i<4 || strncasecmp((char *)buf, "334", 3)) {RETURN(682);}
*username = 0; *username = 0;
i = (int)strlen(param->extusername) + 1; i = (int)strlen((char *)param->extusername) + 1;
memcpy(username+1, param->extusername, i); memcpy(username+1, param->extusername, i);
i++; i++;
res = (int)strlen(param->extpassword); res = (int)strlen((char *)param->extpassword);
memcpy(username + i, param->extpassword, res); memcpy(username + i, param->extpassword, res);
i+=res; i+=res;
en64(username, buf, i); en64(username, buf, i);
i = (int)strlen(buf); i = (int)strlen((char *)buf);
socksend(param->remsock, buf, i, conf.timeouts[STRING_S]); socksend(param->remsock, buf, i, conf.timeouts[STRING_S]);
socksend(param->remsock, "\r\n", 2, conf.timeouts[STRING_S]); socksend(param->remsock, (unsigned char *)"\r\n", 2, conf.timeouts[STRING_S]);
param->statscli64+=(i+2); param->statscli64+=(i+2);
param->nwrites+=2; param->nwrites+=2;
} }
@ -266,7 +266,7 @@ void * smtppchild(struct clientparam* param) {
} }
#endif #endif
i = (int)strlen(command); i = (int)strlen(command);
if(res != 2) socksend(param->remsock, command, i, conf.timeouts[STRING_S]); if(res != 2) socksend(param->remsock, (unsigned char *)command, i, conf.timeouts[STRING_S]);
} }
#ifndef WITHMAIN #ifndef WITHMAIN

View File

@ -22,7 +22,7 @@ int socksend(SOCKET sock, unsigned char * buf, int bufsize, int to){
res = so._poll(&fds, 1, to*1000); res = so._poll(&fds, 1, to*1000);
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue; if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
if(res < 1) break; if(res < 1) break;
res = so._send(sock, buf + sent, bufsize - sent, 0); res = so._send(sock, (char *)buf + sent, bufsize - sent, 0);
if(res < 0) { if(res < 0) {
if(errno == EAGAIN || errno == EINTR) continue; if(errno == EAGAIN || errno == EINTR) continue;
break; break;
@ -45,7 +45,7 @@ int socksendto(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bufs
res = so._poll(&fds, 1, to); res = so._poll(&fds, 1, to);
if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue; if(res < 0 && (errno == EAGAIN || errno == EINTR)) continue;
if(res < 1) break; if(res < 1) break;
res = so._sendto(sock, buf + sent, bufsize - sent, 0, sin, SASIZE(sin)); res = so._sendto(sock, (char *)buf + sent, bufsize - sent, 0, sin, SASIZE(sin));
if(res < 0) { if(res < 0) {
if(errno != EAGAIN && errno != EINTR) break; if(errno != EAGAIN && errno != EINTR) break;
continue; continue;
@ -66,7 +66,7 @@ int sockrecvfrom(SOCKET sock, struct sockaddr * sin, unsigned char * buf, int bu
if (so._poll(&fds, 1, to)<1) return 0; if (so._poll(&fds, 1, to)<1) return 0;
sasize = SASIZE(sin); sasize = SASIZE(sin);
do { do {
res = so._recvfrom(sock, buf, bufsize, 0, (struct sockaddr *)sin, &sasize); res = so._recvfrom(sock, (char *)buf, bufsize, 0, (struct sockaddr *)sin, &sasize);
} while (res < 0 && (errno == EAGAIN || errno == EINTR)); } while (res < 0 && (errno == EAGAIN || errno == EINTR));
return res; return res;
} }

View File

@ -49,14 +49,14 @@ int sockmap(struct clientparam * param, int timeo){
if(action != PASS) return 19; if(action != PASS) return 19;
if(!param->nolongdatfilter){ if(!param->nolongdatfilter){
if(param->cliinbuf > param->clioffset){ if(param->cliinbuf > param->clioffset){
action = handledatfltcli(param, &param->clibuf, &param->clibufsize, param->clioffset, &param->cliinbuf); action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, param->clioffset, (int *)&param->cliinbuf);
if(action == HANDLED){ if(action == HANDLED){
return 0; return 0;
} }
if(action != PASS) return 19; if(action != PASS) return 19;
} }
if(param->srvinbuf > param->srvoffset){ if(param->srvinbuf > param->srvoffset){
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, param->srvoffset, &param->srvinbuf); action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, param->srvoffset, (int *)&param->srvinbuf);
if(action == HANDLED){ if(action == HANDLED){
return 0; return 0;
} }
@ -127,7 +127,7 @@ int sockmap(struct clientparam * param, int timeo){
if(param->bandlimfunc) { if(param->bandlimfunc) {
sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0); sleeptime = (*param->bandlimfunc)(param, param->srvinbuf - param->srvoffset, 0);
} }
res = so._sendto(param->clisock, param->srvbuf + param->srvoffset,(!param->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)&param->sincr, sasize); res = so._sendto(param->clisock, (char *)param->srvbuf + param->srvoffset,(!param->waitserver64 || (param->waitserver64 - received) > (param->srvinbuf - param->srvoffset))? param->srvinbuf - param->srvoffset : (int)(param->waitserver64 - received), 0, (struct sockaddr*)&param->sincr, sasize);
if(res < 0) { if(res < 0) {
if(errno != EAGAIN && errno != EINTR) return 96; if(errno != EAGAIN && errno != EINTR) return 96;
if(errno == EINTR) usleep(SLEEPTIME); if(errno == EINTR) usleep(SLEEPTIME);
@ -153,7 +153,7 @@ int sockmap(struct clientparam * param, int timeo){
sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset); sl1 = (*param->bandlimfunc)(param, 0, param->cliinbuf - param->clioffset);
if(sl1 > sleeptime) sleeptime = sl1; if(sl1 > sleeptime) sleeptime = sl1;
} }
res = so._sendto(param->remsock, param->clibuf + param->clioffset, (!param->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)&param->sinsr, sasize); res = so._sendto(param->remsock, (char *)param->clibuf + param->clioffset, (!param->waitclient64 || (param->waitclient64 - sent) > (param->cliinbuf - param->clioffset))? param->cliinbuf - param->clioffset : (int)(param->waitclient64 - sent), 0, (struct sockaddr*)&param->sinsr, sasize);
if(res < 0) { if(res < 0) {
if(errno != EAGAIN && errno != EINTR) return 97; if(errno != EAGAIN && errno != EINTR) return 97;
if(errno == EINTR) usleep(SLEEPTIME); if(errno == EINTR) usleep(SLEEPTIME);
@ -172,7 +172,7 @@ int sockmap(struct clientparam * param, int timeo){
#if DEBUGLEVEL > 2 #if DEBUGLEVEL > 2
(*param->srv->logfunc)(param, "recv from client"); (*param->srv->logfunc)(param, "recv from client");
#endif #endif
res = so._recvfrom(param->clisock, param->clibuf + param->cliinbuf, param->clibufsize - param->cliinbuf, 0, (struct sockaddr *)&param->sincr, &sasize); res = so._recvfrom(param->clisock, (char *)param->clibuf + param->cliinbuf, param->clibufsize - param->cliinbuf, 0, (struct sockaddr *)&param->sincr, &sasize);
if (res==0) { if (res==0) {
so._shutdown(param->clisock, SHUT_RDWR); so._shutdown(param->clisock, SHUT_RDWR);
so._closesocket(param->clisock); so._closesocket(param->clisock);
@ -187,7 +187,7 @@ int sockmap(struct clientparam * param, int timeo){
} }
param->cliinbuf += res; param->cliinbuf += res;
if(!param->nolongdatfilter){ if(!param->nolongdatfilter){
action = handledatfltcli(param, &param->clibuf, &param->clibufsize, param->cliinbuf - res, &param->cliinbuf); action = handledatfltcli(param, &param->clibuf, (int *)&param->clibufsize, param->cliinbuf - res, (int *)&param->cliinbuf);
if(action == HANDLED){ if(action == HANDLED){
return 0; return 0;
} }
@ -203,7 +203,7 @@ int sockmap(struct clientparam * param, int timeo){
#endif #endif
sasize = sizeof(sin); sasize = sizeof(sin);
res = so._recvfrom(param->remsock, param->srvbuf + param->srvinbuf, param->srvbufsize - param->srvinbuf, 0, (struct sockaddr *)&sin, &sasize); res = so._recvfrom(param->remsock, (char *)param->srvbuf + param->srvinbuf, param->srvbufsize - param->srvinbuf, 0, (struct sockaddr *)&sin, &sasize);
if (res==0) { if (res==0) {
so._shutdown(param->remsock, SHUT_RDWR); so._shutdown(param->remsock, SHUT_RDWR);
so._closesocket(param->remsock); so._closesocket(param->remsock);
@ -220,7 +220,7 @@ int sockmap(struct clientparam * param, int timeo){
param->nreads++; param->nreads++;
param->statssrv64 += res; param->statssrv64 += res;
if(!param->nolongdatfilter){ if(!param->nolongdatfilter){
action = handledatfltsrv(param, &param->srvbuf, &param->srvbufsize, param->srvinbuf - res, &param->srvinbuf); action = handledatfltsrv(param, &param->srvbuf, (int *)&param->srvbufsize, param->srvinbuf - res, (int *)&param->srvinbuf);
if(action == HANDLED){ if(action == HANDLED){
return 0; return 0;
} }

View File

@ -349,7 +349,7 @@ fflush(stderr);
} }
if (fds[1].revents) { if (fds[1].revents) {
sasize = sizeof(sin); sasize = sizeof(sin);
if((len = so._recvfrom(param->clisock, buf, 65535, 0, (struct sockaddr *)&sin, &sasize)) <= 10) { if((len = so._recvfrom(param->clisock, (char *)buf, 65535, 0, (struct sockaddr *)&sin, &sasize)) <= 10) {
param->res = 464; param->res = 464;
break; break;
} }
@ -413,7 +413,7 @@ fflush(stderr);
sasize = sizeof(param->sinsr); sasize = sizeof(param->sinsr);
buf[0]=buf[1]=buf[2]=0; buf[0]=buf[1]=buf[2]=0;
buf[3]=(*SAFAMILY(&param->sinsl) == AF_INET)?1:4; buf[3]=(*SAFAMILY(&param->sinsl) == AF_INET)?1:4;
if((len = so._recvfrom(param->remsock, buf+6+SAADDRLEN(&param->sinsl), 65535 - 10, 0, (struct sockaddr *)&param->sinsr, &sasize)) <= 0) { if((len = so._recvfrom(param->remsock, (char *)buf+6+SAADDRLEN(&param->sinsl), 65535 - 10, 0, (struct sockaddr *)&param->sinsr, &sasize)) <= 0) {
param->res = 468; param->res = 468;
break; break;
} }

View File

@ -613,13 +613,13 @@ struct sockfuncs {
int (WINAPI *_connect)(SOCKET s, const struct sockaddr *name, int namelen); int (WINAPI *_connect)(SOCKET s, const struct sockaddr *name, int namelen);
int (WINAPI *_getpeername)(SOCKET s, struct sockaddr * name, int * namelen); int (WINAPI *_getpeername)(SOCKET s, struct sockaddr * name, int * namelen);
int (WINAPI *_getsockname)(SOCKET s, struct sockaddr * name, int * namelen); int (WINAPI *_getsockname)(SOCKET s, struct sockaddr * name, int * namelen);
int (WINAPI *_getsockopt)(SOCKET s, int level, int optname, void * optval, int * optlen); int (WINAPI *_getsockopt)(SOCKET s, int level, int optname, char * optval, int * optlen);
int (WINAPI *_setsockopt)(SOCKET s, int level, int optname, const void *optval, int optlen); int (WINAPI *_setsockopt)(SOCKET s, int level, int optname, const char *optval, int optlen);
int (WINAPI *_poll)(struct pollfd *fds, unsigned int nfds, int timeout); int (WINAPI *_poll)(struct pollfd *fds, unsigned int nfds, int timeout);
int (WINAPI *_send)(SOCKET s, const void *msg, int len, int flags); int (WINAPI *_send)(SOCKET s, const char *msg, int len, int flags);
int (WINAPI *_sendto)(SOCKET s, const void *msg, int len, int flags, const struct sockaddr *to, int tolen); int (WINAPI *_sendto)(SOCKET s, const char *msg, int len, int flags, const struct sockaddr *to, int tolen);
int (WINAPI *_recv)(SOCKET s, void *buf, int len, int flags); int (WINAPI *_recv)(SOCKET s, char *buf, int len, int flags);
int (WINAPI *_recvfrom)(SOCKET s, void * buf, int len, int flags, struct sockaddr * from, int * fromlen); int (WINAPI *_recvfrom)(SOCKET s, char * buf, int len, int flags, struct sockaddr * from, int * fromlen);
int (WINAPI *_shutdown)(SOCKET s, int how); int (WINAPI *_shutdown)(SOCKET s, int how);
int (WINAPI *_closesocket)(SOCKET s); int (WINAPI *_closesocket)(SOCKET s);
#else #else

View File

@ -59,7 +59,7 @@ void * udppmchild(struct clientparam* param) {
if((param->clisock=so._socket(SASOCK(&param->sincr), SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) { if((param->clisock=so._socket(SASOCK(&param->sincr), SOCK_DGRAM, IPPROTO_UDP)) == INVALID_SOCKET) {
RETURN(818); RETURN(818);
} }
if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (unsigned char *)&ul, sizeof(int))) {RETURN(820);}; if(so._setsockopt(param->clisock, SOL_SOCKET, SO_REUSEADDR, (char *)&ul, sizeof(int))) {RETURN(820);};
ioctlsocket(param->clisock, FIONBIO, &ul); ioctlsocket(param->clisock, FIONBIO, &ul);
size = sizeof(param->sinsl); size = sizeof(param->sinsl);
if(so._getsockname(param->srv->srvsock, (struct sockaddr *)&param->sinsl, &size)) {RETURN(21);}; if(so._getsockname(param->srv->srvsock, (struct sockaddr *)&param->sinsl, &size)) {RETURN(21);};