mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-10 23:20:12 +08:00
Fix warnings
This commit is contained in:
parent
0381461495
commit
8cb8be1be8
@ -215,7 +215,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
|
|
||||||
cheader.updated = conf.time;
|
cheader.updated = conf.time;
|
||||||
lseek(counterd, 0, SEEK_SET);
|
lseek(counterd, 0, SEEK_SET);
|
||||||
write(counterd, &cheader, sizeof(struct counter_header));
|
if(write(counterd, &cheader, sizeof(struct counter_header))){}
|
||||||
for(tl=tlin; tl; tl = tl->next){
|
for(tl=tlin; tl; tl = tl->next){
|
||||||
if(tl->number){
|
if(tl->number){
|
||||||
lseek(counterd,
|
lseek(counterd,
|
||||||
@ -224,7 +224,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
|||||||
crecord.traf64 = tl->traf64;
|
crecord.traf64 = tl->traf64;
|
||||||
crecord.cleared = tl->cleared;
|
crecord.cleared = tl->cleared;
|
||||||
crecord.updated = tl->updated;
|
crecord.updated = tl->updated;
|
||||||
write(counterd, &crecord, sizeof(struct counter_record));
|
if(write(counterd, &crecord, sizeof(struct counter_record))){}
|
||||||
}
|
}
|
||||||
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
|
if(tl->type!=NEVER && timechanged(tl->cleared, conf.time, tl->type)){
|
||||||
tl->cleared = conf.time;
|
tl->cleared = conf.time;
|
||||||
@ -315,7 +315,7 @@ void cyclestep(void){
|
|||||||
else
|
else
|
||||||
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
||||||
}
|
}
|
||||||
system((char *)tmpbuf+1);
|
if(system((char *)tmpbuf+1)){}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1348,7 +1348,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
|
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
|
||||||
SEEK_SET);
|
SEEK_SET);
|
||||||
memset(&crecord, 0, sizeof(struct counter_record));
|
memset(&crecord, 0, sizeof(struct counter_record));
|
||||||
read(conf.counterd, &crecord, sizeof(struct counter_record));
|
if(read(conf.counterd, &crecord, sizeof(struct counter_record)) == sizeof(struct counter_record)){
|
||||||
tl->traf64 = crecord.traf64;
|
tl->traf64 = crecord.traf64;
|
||||||
tl->cleared = crecord.cleared;
|
tl->cleared = crecord.cleared;
|
||||||
tl->updated = crecord.updated;
|
tl->updated = crecord.updated;
|
||||||
@ -1358,6 +1358,7 @@ static int h_ace(int argc, unsigned char **argv){
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
pthread_mutex_lock(&tc_mutex);
|
pthread_mutex_lock(&tc_mutex);
|
||||||
if(!conf.trafcounter){
|
if(!conf.trafcounter){
|
||||||
conf.trafcounter = tl;
|
conf.trafcounter = tl;
|
||||||
@ -1575,7 +1576,7 @@ static int h_chroot(int argc, unsigned char **argv){
|
|||||||
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
||||||
return(5);
|
return(5);
|
||||||
}
|
}
|
||||||
chdir("/");
|
if(chdir("/")){}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
@ -415,7 +415,6 @@ static int WINAPI fp_poll(void *state, struct pollfd *fds, unsigned int nfds, in
|
|||||||
struct fp_stream *fps = NULL;
|
struct fp_stream *fps = NULL;
|
||||||
int res;
|
int res;
|
||||||
unsigned i;
|
unsigned i;
|
||||||
int to;
|
|
||||||
|
|
||||||
for(i = 0; i<nfds; i++){
|
for(i = 0; i<nfds; i++){
|
||||||
res = searchsocket(fds[i].fd, &fps);
|
res = searchsocket(fds[i].fd, &fps);
|
||||||
|
|||||||
@ -32,7 +32,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
|||||||
/*find start service section*/
|
/*find start service section*/
|
||||||
while(!feof(f))
|
while(!feof(f))
|
||||||
{
|
{
|
||||||
fgets(tmpbuf1, 1023,f);
|
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||||
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
|
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
|
||||||
tmpbuf1[0]='\0';
|
tmpbuf1[0]='\0';
|
||||||
}
|
}
|
||||||
@ -51,7 +51,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
|||||||
i=0;
|
i=0;
|
||||||
while ( !feof(f) || i< max_count_str)
|
while ( !feof(f) || i< max_count_str)
|
||||||
{
|
{
|
||||||
fgets(tmpbuf1, 1023,f);
|
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||||
|
|
||||||
if ((strstr(tmpbuf1,stop))!=NULL) { break; }
|
if ((strstr(tmpbuf1,stop))!=NULL) { break; }
|
||||||
|
|
||||||
|
|||||||
@ -527,7 +527,7 @@ for(;;){
|
|||||||
}
|
}
|
||||||
else if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
else if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
||||||
uint64_t newlen64;
|
uint64_t newlen64;
|
||||||
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
newlen64 = (uint64_t) sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||||
if(newlen64 == contentlength64) {
|
if(newlen64 == contentlength64) {
|
||||||
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
||||||
if(action == HANDLED){
|
if(action == HANDLED){
|
||||||
|
|||||||
@ -164,8 +164,8 @@ int sockrecvfrom(struct clientparam *param, SOCKET sock, struct sockaddr * sin,
|
|||||||
|
|
||||||
int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec);
|
||||||
int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec);
|
int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec);
|
||||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
||||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec);
|
unsigned long sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec);
|
||||||
|
|
||||||
int sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to);
|
int sockgetlinebuf(struct clientparam * param, DIRECTION which, unsigned char * buf, int bufsize, int delim, int to);
|
||||||
|
|
||||||
|
|||||||
@ -87,7 +87,7 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
|||||||
return (int)*param->clibuf;
|
return (int)*param->clibuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec){
|
unsigned long sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec){
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(!param->clibuf) return 0;
|
if(!param->clibuf) return 0;
|
||||||
@ -107,7 +107,7 @@ int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec
|
|||||||
return param->cliinbuf;
|
return param->cliinbuf;
|
||||||
}
|
}
|
||||||
|
|
||||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec){
|
unsigned long sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec){
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
if(!param->srvbuf) return 0;
|
if(!param->srvbuf) return 0;
|
||||||
|
|||||||
@ -60,7 +60,8 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
|||||||
int res;
|
int res;
|
||||||
SASIZETYPE sasize;
|
SASIZETYPE sasize;
|
||||||
int needaction = 0;
|
int needaction = 0;
|
||||||
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0, gracetime=0;
|
int graceclinum=0, gracesrvnum=0, graceclitraf=0, gracesrvtraf=0;
|
||||||
|
time_t gracetime = 0;
|
||||||
|
|
||||||
#ifdef WITHSPLICE
|
#ifdef WITHSPLICE
|
||||||
uint64_t inclientpipe = 0, inserverpipe = 0;
|
uint64_t inclientpipe = 0, inserverpipe = 0;
|
||||||
|
|||||||
44
src/tlspr.c
44
src/tlspr.c
@ -38,13 +38,9 @@ int readtls(struct clientparam *param, int direction, unsigned char *buf, int bu
|
|||||||
#define PROTOLEN (32)
|
#define PROTOLEN (32)
|
||||||
|
|
||||||
|
|
||||||
int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos, int *lv, char * proto){
|
int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * snipos, int *lv, char * proto){
|
||||||
int hlen;
|
|
||||||
unsigned offset;
|
unsigned offset;
|
||||||
int slen;
|
unsigned hlen, slen, cslen, elen, snllen, snlen, alpnlen;
|
||||||
int cslen;
|
|
||||||
int elen;
|
|
||||||
int snllen, snlen, alpnlen;
|
|
||||||
int snifound=0;
|
int snifound=0;
|
||||||
|
|
||||||
if(len < 64) return -1;
|
if(len < 64) return -1;
|
||||||
@ -74,7 +70,7 @@ int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos,
|
|||||||
offset += 2;
|
offset += 2;
|
||||||
if(elen+offset != len) return -9;
|
if(elen+offset != len) return -9;
|
||||||
while(elen > 1){
|
while(elen > 1){
|
||||||
int xlen;
|
unsigned xlen;
|
||||||
xlen = size16(hello+offset+2);
|
xlen = size16(hello+offset+2);
|
||||||
if(xlen+4 > elen) return -10;
|
if(xlen+4 > elen) return -10;
|
||||||
if(type == 1 && hello[offset] == 0 && hello[offset+1] == 0){
|
if(type == 1 && hello[offset] == 0 && hello[offset+1] == 0){
|
||||||
@ -112,8 +108,8 @@ int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos,
|
|||||||
return snifound;
|
return snifound;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlstobufcli(struct clientparam *param, int offset){
|
int tlstobufcli(struct clientparam *param){
|
||||||
int len, newlen;
|
unsigned long len, newlen;
|
||||||
if(!param->clibuf){
|
if(!param->clibuf){
|
||||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
||||||
param->clibufsize = SRVBUFSIZE;
|
param->clibufsize = SRVBUFSIZE;
|
||||||
@ -139,11 +135,11 @@ int tlstobufcli(struct clientparam *param, int offset){
|
|||||||
if(param->cliinbuf <= newlen) return -5;
|
if(param->cliinbuf <= newlen) return -5;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len;
|
return (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
int tlstobufsrv(struct clientparam *param, int offset){
|
int tlstobufsrv(struct clientparam *param){
|
||||||
int len, newlen;
|
unsigned long len, newlen;
|
||||||
|
|
||||||
if(param->cliinbuf != param->clioffset){
|
if(param->cliinbuf != param->clioffset){
|
||||||
len = socksend(param, param->remsock, param->clibuf+param->clioffset,param->cliinbuf-param->clioffset, conf.timeouts[STRING_S]);
|
len = socksend(param, param->remsock, param->clibuf+param->clioffset,param->cliinbuf-param->clioffset, conf.timeouts[STRING_S]);
|
||||||
@ -157,20 +153,20 @@ int tlstobufsrv(struct clientparam *param, int offset){
|
|||||||
param->srvbufsize = SRVBUFSIZE;
|
param->srvbufsize = SRVBUFSIZE;
|
||||||
param->srvoffset = param->srvinbuf = 0;
|
param->srvoffset = param->srvinbuf = 0;
|
||||||
}
|
}
|
||||||
len = sockfillbuffsrv(param, offset+5, conf.timeouts[STRING_S]);
|
len = sockfillbuffsrv(param, 5, conf.timeouts[STRING_S]);
|
||||||
if(len < offset+5) return -3;
|
if(len < 5) return -3;
|
||||||
if(param->srvbuf[offset+1] != 3) {
|
if(param->srvbuf[1] != 3) {
|
||||||
return -4;
|
return -4;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
len = offset + 5 + size16(param->srvbuf+offset+3);
|
len = 5 + size16(param->srvbuf+3);
|
||||||
if(len > param->srvbufsize) return -5;
|
if(len > param->srvbufsize) return -5;
|
||||||
for(newlen=param->srvinbuf; newlen < len; newlen=param->srvinbuf){
|
for(newlen=param->srvinbuf; newlen < len; newlen=param->srvinbuf){
|
||||||
sockfillbuffsrv(param, len, conf.timeouts[STRING_S]);
|
sockfillbuffsrv(param, len, conf.timeouts[STRING_S]);
|
||||||
if(param->srvinbuf <= newlen) return -6;
|
if(param->srvinbuf <= newlen) return -6;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return len-offset;
|
return (int)len;
|
||||||
}
|
}
|
||||||
|
|
||||||
void * tlsprchild(struct clientparam* param) {
|
void * tlsprchild(struct clientparam* param) {
|
||||||
@ -181,13 +177,13 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
char proto[PROTOLEN]="-";
|
char proto[PROTOLEN]="-";
|
||||||
int snipos = 0;
|
int snipos = 0;
|
||||||
|
|
||||||
res = tlstobufcli(param, 0);
|
res = tlstobufcli(param);
|
||||||
if(res <= 0 || param->clibuf[0] != 22){
|
if(res <= 0 || param->clibuf[0] != 22){
|
||||||
if(param->srv->requirecert)RETURN(300-res);
|
if(param->srv->requirecert)RETURN(300-res);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
lv = param->clibuf[2];
|
lv = param->clibuf[2];
|
||||||
res = parsehello(1, param->clibuf, res, sni, &snipos, &lv, proto);
|
res = parsehello(1, param->clibuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||||
if(res > 0){
|
if(res > 0){
|
||||||
if(param->hostname){
|
if(param->hostname){
|
||||||
myfree(param->hostname);
|
myfree(param->hostname);
|
||||||
@ -225,20 +221,20 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if(param->srv->requirecert > 1){
|
if(param->srv->requirecert > 1){
|
||||||
res = tlstobufsrv(param, 0);
|
res = tlstobufsrv(param);
|
||||||
if(res <= 0 || param->srvbuf[0] != 22) RETURN(340-res);
|
if(res <= 0 || param->srvbuf[0] != 22) RETURN(340-res);
|
||||||
lv = param->srvbuf[2];
|
lv = param->srvbuf[2];
|
||||||
res = parsehello(2, param->srvbuf, res, sni, &snipos, &lv, proto);
|
res = parsehello(2, param->srvbuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||||
if (res < 0) RETURN(350-res);
|
if (res < 0) RETURN(350-res);
|
||||||
}
|
}
|
||||||
if(param->srv->requirecert > 2){
|
if(param->srv->requirecert > 2){
|
||||||
int srvcert=0, clicert=0, reqcert=0, len, rlen, done;
|
int srvcert=0, clicert=0, reqcert=0, len, done;
|
||||||
if(lv > 3) RETURN(370);
|
if(lv > 3) RETURN(370);
|
||||||
for(done=0;!done;) {
|
for(done=0;!done;) {
|
||||||
len = param->srvinbuf;
|
len = param->srvinbuf;
|
||||||
if(socksend(param, param->clisock, param->srvbuf,len, conf.timeouts[STRING_S]) != len) RETURN(371);
|
if(socksend(param, param->clisock, param->srvbuf,len, conf.timeouts[STRING_S]) != len) RETURN(371);
|
||||||
param->srvinbuf = 0;
|
param->srvinbuf = 0;
|
||||||
res = tlstobufsrv(param, 0);
|
res = tlstobufsrv(param);
|
||||||
if(res <= 0) RETURN(380-res);
|
if(res <= 0) RETURN(380-res);
|
||||||
if(param->srvbuf[0]!= 22) break;
|
if(param->srvbuf[0]!= 22) break;
|
||||||
switch(param->srvbuf[5]){
|
switch(param->srvbuf[5]){
|
||||||
@ -260,7 +256,7 @@ void * tlsprchild(struct clientparam* param) {
|
|||||||
if(param->srv->requirecert > 3){
|
if(param->srv->requirecert > 3){
|
||||||
if(!reqcert) RETURN(374);
|
if(!reqcert) RETURN(374);
|
||||||
for(done=0;!done;) {
|
for(done=0;!done;) {
|
||||||
res = tlstobufcli(param, 0);
|
res = tlstobufcli(param);
|
||||||
if(res <= 0) RETURN(390-res);
|
if(res <= 0) RETURN(390-res);
|
||||||
len = res;
|
len = res;
|
||||||
if(param->clibuf[0]!= 22) break;
|
if(param->clibuf[0]!= 22) break;
|
||||||
|
|||||||
@ -24,7 +24,6 @@ void * udppmchild(struct clientparam* param) {
|
|||||||
SASIZETYPE size;
|
SASIZETYPE size;
|
||||||
unsigned long ul = 1;
|
unsigned long ul = 1;
|
||||||
#endif
|
#endif
|
||||||
struct pollfd fds[256];
|
|
||||||
|
|
||||||
|
|
||||||
if(!param->hostname && parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport))) RETURN(100);
|
if(!param->hostname && parsehostname((char *)param->srv->target, param, ntohs(param->srv->targetport))) RETURN(100);
|
||||||
|
|||||||
@ -593,7 +593,7 @@ void * adminchild(struct clientparam* param) {
|
|||||||
if(writable && !error){
|
if(writable && !error){
|
||||||
fflush(writable);
|
fflush(writable);
|
||||||
#ifndef _WINCE
|
#ifndef _WINCE
|
||||||
ftruncate(fileno(writable), ftell(writable));
|
if(ftruncate(fileno(writable), ftell(writable))){}
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":
|
printstr(&pp, error? "<h3><font color=\"red\">Config file is not writable</font></h3>Make sure you have \"writable\" command in configuration file":
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user