mirror of
https://github.com/3proxy/3proxy.git
synced 2026-04-10 15:10:11 +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;
|
||||
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){
|
||||
if(tl->number){
|
||||
lseek(counterd,
|
||||
@ -224,7 +224,7 @@ void dumpcounters(struct trafcount *tlin, int counterd){
|
||||
crecord.traf64 = tl->traf64;
|
||||
crecord.cleared = tl->cleared;
|
||||
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)){
|
||||
tl->cleared = conf.time;
|
||||
@ -315,7 +315,7 @@ void cyclestep(void){
|
||||
else
|
||||
strcat((char *)tmpbuf, (char *)conf.archiver[i]);
|
||||
}
|
||||
system((char *)tmpbuf+1);
|
||||
if(system((char *)tmpbuf+1)){}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
17
src/conf.c
17
src/conf.c
@ -1348,13 +1348,14 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
sizeof(struct counter_header) + (tl->number - 1) * sizeof(struct counter_record),
|
||||
SEEK_SET);
|
||||
memset(&crecord, 0, sizeof(struct counter_record));
|
||||
read(conf.counterd, &crecord, sizeof(struct counter_record));
|
||||
tl->traf64 = crecord.traf64;
|
||||
tl->cleared = crecord.cleared;
|
||||
tl->updated = crecord.updated;
|
||||
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
||||
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||
return(6);
|
||||
if(read(conf.counterd, &crecord, sizeof(struct counter_record)) == sizeof(struct counter_record)){
|
||||
tl->traf64 = crecord.traf64;
|
||||
tl->cleared = crecord.cleared;
|
||||
tl->updated = crecord.updated;
|
||||
if(tl->cleared < 0 || tl->cleared >= MAX_COUNTER_TIME || tl->updated < 0 || tl->updated >= MAX_COUNTER_TIME){
|
||||
fprintf(stderr, "Invalid, incompatible or corrupted counter file.\n");
|
||||
return(6);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -1575,7 +1576,7 @@ static int h_chroot(int argc, unsigned char **argv){
|
||||
fprintf(stderr, "Unable to set uid %d", (int)uid);
|
||||
return(5);
|
||||
}
|
||||
chdir("/");
|
||||
if(chdir("/")){}
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -415,7 +415,6 @@ static int WINAPI fp_poll(void *state, struct pollfd *fds, unsigned int nfds, in
|
||||
struct fp_stream *fps = NULL;
|
||||
int res;
|
||||
unsigned i;
|
||||
int to;
|
||||
|
||||
for(i = 0; i<nfds; i++){
|
||||
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*/
|
||||
while(!feof(f))
|
||||
{
|
||||
fgets(tmpbuf1, 1023,f);
|
||||
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||
if ((strstr(tmpbuf1,start))!=NULL) { i++; break; }
|
||||
tmpbuf1[0]='\0';
|
||||
}
|
||||
@ -51,7 +51,7 @@ char **load_string(FILE *f,int max_count_str, int *countloadstr,
|
||||
i=0;
|
||||
while ( !feof(f) || i< max_count_str)
|
||||
{
|
||||
fgets(tmpbuf1, 1023,f);
|
||||
if(!fgets(tmpbuf1, 1023,f)) return NULL;
|
||||
|
||||
if ((strstr(tmpbuf1,stop))!=NULL) { break; }
|
||||
|
||||
|
||||
@ -527,7 +527,7 @@ for(;;){
|
||||
}
|
||||
else if(param->ndatfilterscli > 0 && contentlength64 > 0){
|
||||
uint64_t newlen64;
|
||||
newlen64 = sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||
newlen64 = (uint64_t) sockfillbuffcli(param, (unsigned long)contentlength64, CONNECTION_S);
|
||||
if(newlen64 == contentlength64) {
|
||||
action = handledatfltcli(param, ¶m->clibuf, (int *)¶m->clibufsize, 0, (int *)¶m->cliinbuf);
|
||||
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 sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec);
|
||||
int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec);
|
||||
int sockfillbuffsrv(struct clientparam * param, unsigned long size, int timeosec);
|
||||
unsigned long sockfillbuffcli(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);
|
||||
|
||||
|
||||
@ -87,7 +87,7 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
||||
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;
|
||||
|
||||
if(!param->clibuf) return 0;
|
||||
@ -107,7 +107,7 @@ int sockfillbuffcli(struct clientparam * param, unsigned long size, int timeosec
|
||||
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;
|
||||
|
||||
if(!param->srvbuf) return 0;
|
||||
|
||||
@ -60,7 +60,8 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
||||
int res;
|
||||
SASIZETYPE sasize;
|
||||
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
|
||||
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)
|
||||
|
||||
|
||||
int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos, int *lv, char * proto){
|
||||
int hlen;
|
||||
int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * snipos, int *lv, char * proto){
|
||||
unsigned offset;
|
||||
int slen;
|
||||
int cslen;
|
||||
int elen;
|
||||
int snllen, snlen, alpnlen;
|
||||
unsigned hlen, slen, cslen, elen, snllen, snlen, alpnlen;
|
||||
int snifound=0;
|
||||
|
||||
if(len < 64) return -1;
|
||||
@ -74,7 +70,7 @@ int parsehello(int type, unsigned char *hello, int len, char *sni, int * snipos,
|
||||
offset += 2;
|
||||
if(elen+offset != len) return -9;
|
||||
while(elen > 1){
|
||||
int xlen;
|
||||
unsigned xlen;
|
||||
xlen = size16(hello+offset+2);
|
||||
if(xlen+4 > elen) return -10;
|
||||
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;
|
||||
}
|
||||
|
||||
int tlstobufcli(struct clientparam *param, int offset){
|
||||
int len, newlen;
|
||||
int tlstobufcli(struct clientparam *param){
|
||||
unsigned long len, newlen;
|
||||
if(!param->clibuf){
|
||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
||||
param->clibufsize = SRVBUFSIZE;
|
||||
@ -139,11 +135,11 @@ int tlstobufcli(struct clientparam *param, int offset){
|
||||
if(param->cliinbuf <= newlen) return -5;
|
||||
}
|
||||
}
|
||||
return len;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
int tlstobufsrv(struct clientparam *param, int offset){
|
||||
int len, newlen;
|
||||
int tlstobufsrv(struct clientparam *param){
|
||||
unsigned long len, newlen;
|
||||
|
||||
if(param->cliinbuf != param->clioffset){
|
||||
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->srvoffset = param->srvinbuf = 0;
|
||||
}
|
||||
len = sockfillbuffsrv(param, offset+5, conf.timeouts[STRING_S]);
|
||||
if(len < offset+5) return -3;
|
||||
if(param->srvbuf[offset+1] != 3) {
|
||||
len = sockfillbuffsrv(param, 5, conf.timeouts[STRING_S]);
|
||||
if(len < 5) return -3;
|
||||
if(param->srvbuf[1] != 3) {
|
||||
return -4;
|
||||
}
|
||||
else {
|
||||
len = offset + 5 + size16(param->srvbuf+offset+3);
|
||||
len = 5 + size16(param->srvbuf+3);
|
||||
if(len > param->srvbufsize) return -5;
|
||||
for(newlen=param->srvinbuf; newlen < len; newlen=param->srvinbuf){
|
||||
sockfillbuffsrv(param, len, conf.timeouts[STRING_S]);
|
||||
if(param->srvinbuf <= newlen) return -6;
|
||||
}
|
||||
}
|
||||
return len-offset;
|
||||
return (int)len;
|
||||
}
|
||||
|
||||
void * tlsprchild(struct clientparam* param) {
|
||||
@ -181,13 +177,13 @@ void * tlsprchild(struct clientparam* param) {
|
||||
char proto[PROTOLEN]="-";
|
||||
int snipos = 0;
|
||||
|
||||
res = tlstobufcli(param, 0);
|
||||
res = tlstobufcli(param);
|
||||
if(res <= 0 || param->clibuf[0] != 22){
|
||||
if(param->srv->requirecert)RETURN(300-res);
|
||||
}
|
||||
else {
|
||||
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(param->hostname){
|
||||
myfree(param->hostname);
|
||||
@ -225,20 +221,20 @@ void * tlsprchild(struct clientparam* param) {
|
||||
}
|
||||
|
||||
if(param->srv->requirecert > 1){
|
||||
res = tlstobufsrv(param, 0);
|
||||
res = tlstobufsrv(param);
|
||||
if(res <= 0 || param->srvbuf[0] != 22) RETURN(340-res);
|
||||
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(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);
|
||||
for(done=0;!done;) {
|
||||
len = param->srvinbuf;
|
||||
if(socksend(param, param->clisock, param->srvbuf,len, conf.timeouts[STRING_S]) != len) RETURN(371);
|
||||
param->srvinbuf = 0;
|
||||
res = tlstobufsrv(param, 0);
|
||||
res = tlstobufsrv(param);
|
||||
if(res <= 0) RETURN(380-res);
|
||||
if(param->srvbuf[0]!= 22) break;
|
||||
switch(param->srvbuf[5]){
|
||||
@ -260,7 +256,7 @@ void * tlsprchild(struct clientparam* param) {
|
||||
if(param->srv->requirecert > 3){
|
||||
if(!reqcert) RETURN(374);
|
||||
for(done=0;!done;) {
|
||||
res = tlstobufcli(param, 0);
|
||||
res = tlstobufcli(param);
|
||||
if(res <= 0) RETURN(390-res);
|
||||
len = res;
|
||||
if(param->clibuf[0]!= 22) break;
|
||||
|
||||
@ -24,7 +24,6 @@ void * udppmchild(struct clientparam* param) {
|
||||
SASIZETYPE size;
|
||||
unsigned long ul = 1;
|
||||
#endif
|
||||
struct pollfd fds[256];
|
||||
|
||||
|
||||
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){
|
||||
fflush(writable);
|
||||
#ifndef _WINCE
|
||||
ftruncate(fileno(writable), ftell(writable));
|
||||
if(ftruncate(fileno(writable), ftell(writable))){}
|
||||
#endif
|
||||
}
|
||||
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