mirror of
https://github.com/3proxy/3proxy.git
synced 2026-05-13 13:30:12 +08:00
Use standard malloc functions
Some checks are pending
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
Some checks are pending
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI Linux / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI MacOS / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI Windows / ${{ matrix.target }} (windows-2022) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (macos-15) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (ubuntu-latest) (push) Waiting to run
C/C++ CI cmake / ${{ matrix.target }} (windows-2022) (push) Waiting to run
This commit is contained in:
parent
a338a0c689
commit
830b2d39d1
@ -489,7 +489,7 @@ int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPWSTR lpCmdLine, int
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
conf.conffile = mystrdup((argc==2)?argv[1]:(char*)DEFAULTCONFIG);
|
||||
conf.conffile = strdup((argc==2)?argv[1]:(char*)DEFAULTCONFIG);
|
||||
if(conf.conffile && *conf.conffile != '-') {
|
||||
fp = confopen();
|
||||
#ifndef _WIN32
|
||||
|
||||
@ -93,8 +93,8 @@ int cacheauth(struct clientparam * param){
|
||||
}
|
||||
|
||||
if(!(conf.authcachetype&2) && *ac.username){
|
||||
if(param->username) myfree(param->username);
|
||||
param->username = (unsigned char *)mystrdup((char *)ac.username);
|
||||
if(param->username) free(param->username);
|
||||
param->username = (unsigned char *)strdup((char *)ac.username);
|
||||
}
|
||||
if((conf.authcachetype & 32)){
|
||||
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||
|
||||
@ -13,7 +13,7 @@ void * autochild(struct clientparam* param) {
|
||||
int len;
|
||||
|
||||
if(!param->clibuf){
|
||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return 0;
|
||||
if(!(param->clibuf = malloc(SRVBUFSIZE))) return 0;
|
||||
param->clibufsize = SRVBUFSIZE;
|
||||
param->clioffset = param->cliinbuf = 0;
|
||||
}
|
||||
|
||||
20
src/common.c
20
src/common.c
@ -463,8 +463,8 @@ int parsehostname(char *hostname, struct clientparam *param, uint16_t port){
|
||||
*se = 0;
|
||||
}
|
||||
if(hostname != (char *)param->hostname){
|
||||
if(param->hostname) myfree(param->hostname);
|
||||
param->hostname = (unsigned char *)mystrdup(hostname + (se!=0));
|
||||
if(param->hostname) free(param->hostname);
|
||||
param->hostname = (unsigned char *)strdup(hostname + (se!=0));
|
||||
}
|
||||
if(sp){
|
||||
port = atoi(sp+1);
|
||||
@ -486,12 +486,12 @@ int parseusername(char *username, struct clientparam *param, int extpasswd){
|
||||
*se = 0;
|
||||
if(sp) *sp = 0;
|
||||
if(*(sb+1)) {
|
||||
if(param->password) myfree(param->password);
|
||||
param->password = (unsigned char *)mystrdup(sb+1);
|
||||
if(param->password) free(param->password);
|
||||
param->password = (unsigned char *)strdup(sb+1);
|
||||
}
|
||||
if(*username) {
|
||||
if(param->username) myfree(param->username);
|
||||
param->username = (unsigned char *)mystrdup(username);
|
||||
if(param->username) free(param->username);
|
||||
param->username = (unsigned char *)strdup(username);
|
||||
}
|
||||
username = se+1;
|
||||
}
|
||||
@ -499,12 +499,12 @@ int parseusername(char *username, struct clientparam *param, int extpasswd){
|
||||
if(!sp) sp = strchr(username, ':');
|
||||
if(sp){
|
||||
*sp = 0;
|
||||
if(param->extpassword) myfree(param->extpassword);
|
||||
param->extpassword = (unsigned char *) mystrdup(sp+1);
|
||||
if(param->extpassword) free(param->extpassword);
|
||||
param->extpassword = (unsigned char *) strdup(sp+1);
|
||||
}
|
||||
}
|
||||
if(param->extusername) myfree(param->extusername);
|
||||
param->extusername = (unsigned char *)mystrdup(username);
|
||||
if(param->extusername) free(param->extusername);
|
||||
param->extusername = (unsigned char *)strdup(username);
|
||||
if(sb) *sb = ':';
|
||||
if(se) *se = ':';
|
||||
if(sp) *sp = ':';
|
||||
|
||||
118
src/conf.c
118
src/conf.c
@ -320,7 +320,7 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
notchanged = 1;
|
||||
}
|
||||
if(!notchanged && conf.logtarget){
|
||||
myfree(conf.logtarget);
|
||||
free(conf.logtarget);
|
||||
conf.logtarget = NULL;
|
||||
}
|
||||
if(argc > 1) {
|
||||
@ -328,7 +328,7 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
conf.logfunc = lognone;
|
||||
return 0;
|
||||
}
|
||||
if(!notchanged) conf.logtarget = (unsigned char *)mystrdup((char *)argv[1]);
|
||||
if(!notchanged) conf.logtarget = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(*argv[1]=='@'){
|
||||
#ifndef _WIN32
|
||||
conf.logfunc = logsyslog;
|
||||
@ -358,8 +358,8 @@ static int h_log(int argc, unsigned char ** argv){
|
||||
conf.logfunc = logstdout;
|
||||
if(notchanged) return 0;
|
||||
conf.logtime = time(0);
|
||||
if(conf.logname)myfree(conf.logname);
|
||||
conf.logname = (unsigned char *)mystrdup((char *)argv[1]);
|
||||
if(conf.logname)free(conf.logname);
|
||||
conf.logname = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(conf.stdlog) conf.stdlog = freopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a", conf.stdlog);
|
||||
else conf.stdlog = fopen((char *)dologname (tmpbuf, conf.logname, NULL, conf.logtype, conf.logtime), "a");
|
||||
if(!conf.stdlog){
|
||||
@ -400,8 +400,8 @@ static int h_daemon(int argc, unsigned char **argv){
|
||||
}
|
||||
|
||||
static int h_config(int argc, unsigned char **argv){
|
||||
if(conf.conffile)myfree(conf.conffile);
|
||||
conf.conffile = mystrdup((char *)argv[1]);
|
||||
if(conf.conffile)free(conf.conffile);
|
||||
conf.conffile = strdup((char *)argv[1]);
|
||||
if(!conf.conffile) return 21;
|
||||
return 0;
|
||||
}
|
||||
@ -423,10 +423,10 @@ static int h_include(int argc, unsigned char **argv){
|
||||
static int h_archiver(int argc, unsigned char **argv){
|
||||
int j;
|
||||
|
||||
conf.archiver = myalloc(argc * sizeof(char *));
|
||||
conf.archiver = malloc(argc * sizeof(char *));
|
||||
if(conf.archiver) {
|
||||
conf.archiverc = argc;
|
||||
for(j = 0; j < conf.archiverc; j++) conf.archiver[j] = (unsigned char *)mystrdup((char *)argv[j]);
|
||||
for(j = 0; j < conf.archiverc; j++) conf.archiver[j] = (unsigned char *)strdup((char *)argv[j]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -452,8 +452,8 @@ static int h_counter(int argc, unsigned char **argv){
|
||||
}
|
||||
if(argc >=4) {
|
||||
conf.countertype = getrotate(*argv[2]);
|
||||
if(conf.counterfile) myfree(conf.counterfile);
|
||||
conf.counterfile = mystrdup((char *)argv[3]);
|
||||
if(conf.counterfile) free(conf.counterfile);
|
||||
conf.counterfile = strdup((char *)argv[3]);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@ -470,8 +470,8 @@ static int h_maxseg(int argc, unsigned char **argv){
|
||||
|
||||
static int h_logformat(int argc, unsigned char **argv){
|
||||
unsigned char * old = conf.logformat;
|
||||
conf.logformat = (unsigned char *)mystrdup((char *)argv[1]);
|
||||
if(old) myfree(old);
|
||||
conf.logformat = (unsigned char *)strdup((char *)argv[1]);
|
||||
if(old) free(old);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -500,7 +500,7 @@ static int h_auth(int argc, unsigned char **argv){
|
||||
for(argc--; argc; argc--){
|
||||
for(au = authfuncs; au; au=au->next){
|
||||
if(!strcmp((char *)argv[argc], au->desc)){
|
||||
newau = myalloc(sizeof(struct auth));
|
||||
newau = malloc(sizeof(struct auth));
|
||||
if(!newau) {
|
||||
return 21;
|
||||
}
|
||||
@ -702,8 +702,8 @@ static int h_nsrecord(int argc, unsigned char **argv){
|
||||
}
|
||||
|
||||
static int h_dialer(int argc, unsigned char **argv){
|
||||
if(conf.demanddialprog) myfree(conf.demanddialprog);
|
||||
conf.demanddialprog = mystrdup((char *)argv[1]);
|
||||
if(conf.demanddialprog) free(conf.demanddialprog);
|
||||
conf.demanddialprog = strdup((char *)argv[1]);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -732,14 +732,14 @@ static int h_pidfile(int argc, unsigned char **argv){
|
||||
static int h_monitor(int argc, unsigned char **argv){
|
||||
struct filemon * fm;
|
||||
|
||||
fm = myalloc(sizeof (struct filemon));
|
||||
fm = malloc(sizeof (struct filemon));
|
||||
if(!fm) return 21;
|
||||
if(stat((char *)argv[1], &fm->sb)){
|
||||
myfree(fm);
|
||||
free(fm);
|
||||
fprintf(stderr, "Warning: file %s doesn't exist on line %d\n", argv[1], linenum);
|
||||
}
|
||||
else {
|
||||
fm->path = mystrdup((char *)argv[1]);
|
||||
fm->path = strdup((char *)argv[1]);
|
||||
if(!fm->path) return 21;
|
||||
fm->next = conf.fmon;
|
||||
conf.fmon = fm;
|
||||
@ -784,7 +784,7 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
}
|
||||
acl->action = 2;
|
||||
|
||||
chains = myalloc(sizeof(struct chain));
|
||||
chains = malloc(sizeof(struct chain));
|
||||
if(!chains){
|
||||
return(21);
|
||||
}
|
||||
@ -792,7 +792,7 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
chains->weight = (unsigned)atoi((char *)argv[1]);
|
||||
if(chains->weight == 0 || chains->weight >1000) {
|
||||
fprintf(stderr, "Chaining error: bad chain weight %u line %d\n", chains->weight, linenum);
|
||||
myfree(chains);
|
||||
free(chains);
|
||||
return(3);
|
||||
}
|
||||
for(i = 0; redirs[i].name ; i++){
|
||||
@ -808,7 +808,7 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
}
|
||||
if(!redirs[i].name) {
|
||||
fprintf(stderr, "Chaining error: bad chain type (%s)\n", argv[2]);
|
||||
myfree(chains);
|
||||
free(chains);
|
||||
return(4);
|
||||
}
|
||||
#ifdef WITH_UN
|
||||
@ -820,15 +820,15 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
cidr = strchr((char *)argv[3], '/');
|
||||
if(cidr) *cidr = 0;
|
||||
if(!getip46(46, argv[3], (struct sockaddr *)&chains->addr)) {
|
||||
myfree(chains);
|
||||
free(chains);
|
||||
return (5);
|
||||
}
|
||||
#ifdef WITH_UN
|
||||
}
|
||||
#endif
|
||||
chains->exthost = (unsigned char *)mystrdup((char *)argv[3]);
|
||||
chains->exthost = (unsigned char *)strdup((char *)argv[3]);
|
||||
if(!chains->exthost) {
|
||||
myfree(chains);
|
||||
free(chains);
|
||||
return 21;
|
||||
}
|
||||
if(cidr){
|
||||
@ -836,8 +836,8 @@ static int h_parent(int argc, unsigned char **argv){
|
||||
chains->cidr = atoi(cidr + 1);
|
||||
}
|
||||
*SAPORT(&chains->addr) = htons((uint16_t)atoi((char *)argv[4]));
|
||||
if(argc > 5) chains->extuser = (unsigned char *)mystrdup((char *)argv[5]);
|
||||
if(argc > 6) chains->extpass = (unsigned char *)mystrdup((char *)argv[6]);
|
||||
if(argc > 5) chains->extuser = (unsigned char *)strdup((char *)argv[5]);
|
||||
if(argc > 6) chains->extpass = (unsigned char *)strdup((char *)argv[6]);
|
||||
if(!acl->chains) {
|
||||
acl->chains = chains;
|
||||
}
|
||||
@ -923,7 +923,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
struct hostname *hostnamel=NULL;
|
||||
int res;
|
||||
|
||||
acl = myalloc(sizeof(struct ace));
|
||||
acl = malloc(sizeof(struct ace));
|
||||
if(!acl) return acl;
|
||||
memset(acl, 0, sizeof(struct ace));
|
||||
if(argc > 0 && strcmp("*", (char *)argv[0])) {
|
||||
@ -931,10 +931,10 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
arg = (unsigned char *)strtok((char *)arg, ",");
|
||||
if(arg) do {
|
||||
if(!acl->users) {
|
||||
acl->users = userl = myalloc(sizeof(struct userlist));
|
||||
acl->users = userl = malloc(sizeof(struct userlist));
|
||||
}
|
||||
else {
|
||||
userl->next = myalloc(sizeof(struct userlist));
|
||||
userl->next = malloc(sizeof(struct userlist));
|
||||
userl = userl -> next;
|
||||
}
|
||||
if(!userl) {
|
||||
@ -942,7 +942,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
return(NULL);
|
||||
}
|
||||
memset(userl, 0, sizeof(struct userlist));
|
||||
userl->user=(unsigned char*)mystrdup((char *)arg);
|
||||
userl->user=(unsigned char*)strdup((char *)arg);
|
||||
if(!userl->user) return NULL;
|
||||
} while((arg = (unsigned char *)strtok((char *)NULL, ",")));
|
||||
}
|
||||
@ -950,10 +950,10 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
arg = (unsigned char *)strtok((char *)argv[1], ",");
|
||||
if(arg) do {
|
||||
if(!acl->src) {
|
||||
acl->src = ipl = myalloc(sizeof(struct iplist));
|
||||
acl->src = ipl = malloc(sizeof(struct iplist));
|
||||
}
|
||||
else {
|
||||
ipl->next = myalloc(sizeof(struct iplist));
|
||||
ipl->next = malloc(sizeof(struct iplist));
|
||||
ipl = ipl -> next;
|
||||
}
|
||||
if(!ipl) {
|
||||
@ -978,10 +978,10 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
if(scanipl(arg, &tmpip)){
|
||||
if(!arglen) continue;
|
||||
if(!acl->dstnames) {
|
||||
acl->dstnames = hostnamel = myalloc(sizeof(struct hostname));
|
||||
acl->dstnames = hostnamel = malloc(sizeof(struct hostname));
|
||||
}
|
||||
else {
|
||||
hostnamel->next = myalloc(sizeof(struct hostname));
|
||||
hostnamel->next = malloc(sizeof(struct hostname));
|
||||
hostnamel = hostnamel -> next;
|
||||
}
|
||||
if(!hostnamel){
|
||||
@ -1001,7 +1001,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
arglen--;
|
||||
hostnamel->matchtype ^= MATCHBEGIN;
|
||||
}
|
||||
hostnamel->name = (unsigned char *) mystrdup( (char *)pattern);
|
||||
hostnamel->name = (unsigned char *) strdup( (char *)pattern);
|
||||
if(!hostnamel->name) {
|
||||
fprintf(stderr, "No memory for ACL entry, line %d\n", linenum);
|
||||
return(NULL);
|
||||
@ -1010,10 +1010,10 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
else {
|
||||
|
||||
if(!acl->dst) {
|
||||
acl->dst = ipl = myalloc(sizeof(struct iplist));
|
||||
acl->dst = ipl = malloc(sizeof(struct iplist));
|
||||
}
|
||||
else {
|
||||
ipl->next = myalloc(sizeof(struct iplist));
|
||||
ipl->next = malloc(sizeof(struct iplist));
|
||||
ipl = ipl -> next;
|
||||
}
|
||||
if(!ipl) {
|
||||
@ -1028,10 +1028,10 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
arg = (unsigned char *)strtok((char *)argv[3], ",");
|
||||
if(arg) do {
|
||||
if(!acl->ports) {
|
||||
acl->ports = portl = myalloc(sizeof(struct portlist));
|
||||
acl->ports = portl = malloc(sizeof(struct portlist));
|
||||
}
|
||||
else {
|
||||
portl->next = myalloc(sizeof(struct portlist));
|
||||
portl->next = malloc(sizeof(struct portlist));
|
||||
portl = portl -> next;
|
||||
}
|
||||
if(!portl) {
|
||||
@ -1157,7 +1157,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
|
||||
t2 = (t2 * 60) + (arg[12] - '0') * 10 + (arg[13] - '0');
|
||||
t2 = (t2 * 60) + (arg[15] - '0') * 10 + (arg[16] - '0');
|
||||
if(t2 < t1) break;
|
||||
sp = myalloc(sizeof(struct period));
|
||||
sp = malloc(sizeof(struct period));
|
||||
if(sp){
|
||||
sp->fromtime = t1;
|
||||
sp->totime = t2;
|
||||
@ -1236,7 +1236,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
acl->action = res;
|
||||
switch(acl->action){
|
||||
case REDIRECT:
|
||||
acl->chains = myalloc(sizeof(struct chain));
|
||||
acl->chains = malloc(sizeof(struct chain));
|
||||
if(!acl->chains) {
|
||||
freeacl(acl);
|
||||
return(21);
|
||||
@ -1263,7 +1263,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
break;
|
||||
case CONNLIM:
|
||||
case NOCONNLIM:
|
||||
ncl = myalloc(sizeof(struct connlim));
|
||||
ncl = malloc(sizeof(struct connlim));
|
||||
if(!ncl) {
|
||||
freeacl(acl);
|
||||
return(21);
|
||||
@ -1290,7 +1290,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
case BANDLIM:
|
||||
case NOBANDLIM:
|
||||
|
||||
nbl = myalloc(sizeof(struct bandlim));
|
||||
nbl = malloc(sizeof(struct bandlim));
|
||||
if(!nbl) {
|
||||
freeacl(acl);
|
||||
return(21);
|
||||
@ -1300,7 +1300,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
if(acl->action == BANDLIM) {
|
||||
sscanf((char *)argv[1], "%u", &nbl->rate);
|
||||
if(nbl->rate < 300) {
|
||||
myfree(nbl);
|
||||
free(nbl);
|
||||
freeacl(acl);
|
||||
fprintf(stderr, "Wrong bandwidth specified, line %d\n", linenum);
|
||||
return(4);
|
||||
@ -1340,7 +1340,7 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
case COUNTALL:
|
||||
case NOCOUNTALL:
|
||||
if(!conf.trafcountfunc) conf.trafcountfunc = trafcountfunc;
|
||||
tl = myalloc(sizeof(struct trafcount));
|
||||
tl = malloc(sizeof(struct trafcount));
|
||||
if(!tl) {
|
||||
freeacl(acl);
|
||||
return(21);
|
||||
@ -1354,14 +1354,14 @@ static int h_ace(int argc, unsigned char **argv){
|
||||
tl->comment = ( char *)argv[1];
|
||||
while(isdigit(*tl->comment))tl->comment++;
|
||||
if(*tl->comment== '/')tl->comment++;
|
||||
tl->comment = mystrdup(tl->comment);
|
||||
tl->comment = strdup(tl->comment);
|
||||
|
||||
sscanf((char *)argv[1], "%u", &tl->number);
|
||||
sscanf((char *)argv[3], "%lu", &lim);
|
||||
tl->type = getrotate(*argv[2]);
|
||||
tl->traflim64 = ((uint64_t)lim)*(1024*1024);
|
||||
if(!tl->traflim64) {
|
||||
myfree(tl);
|
||||
free(tl);
|
||||
freeacl(acl);
|
||||
fprintf(stderr, "Wrong traffic limit specified, line %d\n", linenum);
|
||||
return(6);
|
||||
@ -1598,7 +1598,7 @@ static int h_chroot(int argc, unsigned char **argv){
|
||||
p--;
|
||||
*p = 0;
|
||||
}
|
||||
chrootp = mystrdup((char *)argv[1]);
|
||||
chrootp = strdup((char *)argv[1]);
|
||||
if(!chrootp) return 21;
|
||||
}
|
||||
if (gid && setregid(gid,gid)) {
|
||||
@ -1751,7 +1751,7 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
|
||||
}
|
||||
if((*bufsize - *inbuf) <STRINGBUF){
|
||||
*bufsize += STRINGBUF;
|
||||
if(!(buf = myrealloc(buf, *bufsize))){
|
||||
if(!(buf = realloc(buf, *bufsize))){
|
||||
fprintf(stderr, "Failed to allocate memory for %s\n", incbegin+1);
|
||||
close(fd);
|
||||
return -1;
|
||||
@ -1804,7 +1804,7 @@ int readconfig(FILE * fp){
|
||||
struct commands * cm;
|
||||
int res = 0;
|
||||
|
||||
if( !(buf = myalloc(bufsize)) || ! (argv = myalloc((NPARAMS + 1) * sizeof(unsigned char *))) ) {
|
||||
if( !(buf = malloc(bufsize)) || ! (argv = malloc((NPARAMS + 1) * sizeof(unsigned char *))) ) {
|
||||
fprintf(stderr, "No memory for configuration");
|
||||
return(10);
|
||||
}
|
||||
@ -1851,8 +1851,8 @@ int readconfig(FILE * fp){
|
||||
fprintf(stderr, "Unknown command: '%s' line %d\n", argv[0], linenum);
|
||||
return(linenum);
|
||||
}
|
||||
myfree(buf);
|
||||
myfree(argv);
|
||||
free(buf);
|
||||
free(argv);
|
||||
return 0;
|
||||
|
||||
}
|
||||
@ -1861,8 +1861,8 @@ int readconfig(FILE * fp){
|
||||
|
||||
void freepwl(struct passwords *pwl){
|
||||
for(; pwl; pwl = (struct passwords *)itfree(pwl, pwl->next)){
|
||||
if(pwl->user)myfree(pwl->user);
|
||||
if(pwl->password)myfree(pwl->password);
|
||||
if(pwl->user)free(pwl->user);
|
||||
if(pwl->password)free(pwl->password);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1944,7 +1944,7 @@ void freeconf(struct extparam *confp){
|
||||
}
|
||||
if(tc)dumpcounters(tc,counterd);
|
||||
for(; tc; tc = (struct trafcount *) itfree(tc, tc->next)){
|
||||
if(tc->comment)myfree(tc->comment);
|
||||
if(tc->comment)free(tc->comment);
|
||||
freeacl(tc->ace);
|
||||
}
|
||||
|
||||
@ -1958,14 +1958,14 @@ void freeconf(struct extparam *confp){
|
||||
close(counterd);
|
||||
}
|
||||
for(; fm; fm = (struct filemon *)itfree(fm, fm->next)){
|
||||
if(fm->path) myfree(fm->path);
|
||||
if(fm->path) free(fm->path);
|
||||
}
|
||||
if(logformat) {
|
||||
myfree(logformat);
|
||||
free(logformat);
|
||||
}
|
||||
if(archiver) {
|
||||
for(i = 0; i < archiverc; i++) myfree(archiver[i]);
|
||||
myfree(archiver);
|
||||
for(i = 0; i < archiverc; i++) free(archiver[i]);
|
||||
free(archiver);
|
||||
}
|
||||
havelog = 0;
|
||||
}
|
||||
|
||||
@ -33,7 +33,7 @@ void * dnsprchild(struct clientparam* param) {
|
||||
#endif
|
||||
|
||||
|
||||
if(!(bbuf = myalloc(BUFSIZE+2))){
|
||||
if(!(bbuf = malloc(BUFSIZE+2))){
|
||||
param->srv->fds.events = POLLIN;
|
||||
RETURN (21);
|
||||
}
|
||||
@ -75,7 +75,7 @@ void * dnsprchild(struct clientparam* param) {
|
||||
}
|
||||
if(len > (i-4)) {RETURN(817);}
|
||||
|
||||
host = mystrdup((char *)buf+13);
|
||||
host = strdup((char *)buf+13);
|
||||
if(!host) {RETURN(21);}
|
||||
|
||||
for(s2 = buf + 12; (s1 = (unsigned char *)strchr((char *)s2 + 1, '.')); s2 = s1)*s2 = (unsigned char)((s1 - s2) - 1);
|
||||
@ -200,8 +200,8 @@ CLEANRET:
|
||||
}
|
||||
dolog(param, buf);
|
||||
}
|
||||
if(bbuf)myfree(bbuf);
|
||||
if(host)myfree(host);
|
||||
if(bbuf)free(bbuf);
|
||||
if(host)free(host);
|
||||
#ifndef _WIN32
|
||||
param->clisock = INVALID_SOCKET;
|
||||
#endif
|
||||
|
||||
16
src/ftppr.c
16
src/ftppr.c
@ -24,7 +24,7 @@ void * ftpprchild(struct clientparam* param) {
|
||||
struct linger lg;
|
||||
struct pollfd fds;
|
||||
|
||||
if(!(buf = myalloc(BUFSIZE))) RETURN(876);
|
||||
if(!(buf = malloc(BUFSIZE))) RETURN(876);
|
||||
param->ctrlsock = param->clisock;
|
||||
param->operation = CONNECT;
|
||||
lg.l_onoff = 1;
|
||||
@ -38,7 +38,7 @@ void * ftpprchild(struct clientparam* param) {
|
||||
if(i<4) {RETURN(802);}
|
||||
buf[i] = 0;
|
||||
if ((se=(unsigned char *)strchr((char *)buf, '\r'))) *se = 0;
|
||||
if (req) myfree (req);
|
||||
if (req) free (req);
|
||||
req = NULL;
|
||||
|
||||
if (!strncasecmp((char *)buf, "OPEN ", 5)){
|
||||
@ -64,14 +64,14 @@ void * ftpprchild(struct clientparam* param) {
|
||||
|
||||
}
|
||||
else if (!strncasecmp((char *)buf, "PASS ", 5)){
|
||||
param->extpassword = (unsigned char *)mystrdup((char *)buf+5);
|
||||
param->extpassword = (unsigned char *)strdup((char *)buf+5);
|
||||
inbuf = BUFSIZE;
|
||||
res = ftplogin(param, (char *)buf, &inbuf);
|
||||
param->res = res;
|
||||
if(inbuf && inbuf != BUFSIZE && socksend(param, param->ctrlsock, buf, inbuf, conf.timeouts[STRING_S])!=inbuf) {RETURN (807);}
|
||||
if(!res) status = 3;
|
||||
sprintf((char *)buf, "%.128s@%.128s%c%hu", param->extusername, param->hostname, (ntohs(*SAPORT(¶m->sinsr))==21)?0:':', ntohs(*SAPORT(¶m->sinsr)));
|
||||
req = mystrdup((char *)buf);
|
||||
req = strdup((char *)buf);
|
||||
#ifndef WITHMAIN
|
||||
{
|
||||
int action, reqbufsize, reqsize;
|
||||
@ -221,7 +221,7 @@ void * ftpprchild(struct clientparam* param) {
|
||||
ss = INVALID_SOCKET;
|
||||
}
|
||||
if(clidatasock == INVALID_SOCKET){RETURN(828);}
|
||||
req = mystrdup((char *)buf);
|
||||
req = strdup((char *)buf);
|
||||
buf[4] = 0;
|
||||
status = 3;
|
||||
ss = ftpcommand(param, buf, arg? buf+5 : NULL);
|
||||
@ -278,7 +278,7 @@ void * ftpprchild(struct clientparam* param) {
|
||||
continue;
|
||||
}
|
||||
if(!strncasecmp((char *)buf, "QUIT", 4)) status = 5;
|
||||
if(!strncasecmp((char *)buf, "CWD ", 4)) req = mystrdup((char *)buf);
|
||||
if(!strncasecmp((char *)buf, "CWD ", 4)) req = strdup((char *)buf);
|
||||
i = (int)strlen((char *)buf);
|
||||
buf[i++] = '\r';
|
||||
buf[i++] = '\n';
|
||||
@ -318,8 +318,8 @@ CLEANRET:
|
||||
if(param->res != 0 || param->statscli64 || param->statssrv64 ){
|
||||
dolog(param, (unsigned char *)((req && (param->res > 802))? req:NULL));
|
||||
}
|
||||
if(req) myfree(req);
|
||||
if(buf) myfree(buf);
|
||||
if(req) free(req);
|
||||
if(buf) free(buf);
|
||||
freeparam(param);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
30
src/hash.c
30
src/hash.c
@ -11,15 +11,15 @@ struct hashentry {
|
||||
void destroyhashtable(struct hashtable *ht){
|
||||
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||
if(ht->ihashtable){
|
||||
myfree(ht->ihashtable);
|
||||
free(ht->ihashtable);
|
||||
ht->ihashtable = NULL;
|
||||
}
|
||||
if(ht->hashvalues){
|
||||
myfree(ht->hashvalues);
|
||||
free(ht->hashvalues);
|
||||
ht->hashvalues = NULL;
|
||||
}
|
||||
if(ht->hashhashvalues){
|
||||
myfree(ht->hashhashvalues);
|
||||
free(ht->hashhashvalues);
|
||||
ht->hashhashvalues = NULL;
|
||||
}
|
||||
ht->poolsize = 0;
|
||||
@ -53,15 +53,15 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
|
||||
if(ht->ihashtable){
|
||||
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||
if(ht->ihashtable){
|
||||
myfree(ht->ihashtable);
|
||||
free(ht->ihashtable);
|
||||
ht->ihashtable = NULL;
|
||||
}
|
||||
if(ht->hashvalues){
|
||||
myfree(ht->hashvalues);
|
||||
free(ht->hashvalues);
|
||||
ht->hashvalues = NULL;
|
||||
}
|
||||
if(ht->hashhashvalues){
|
||||
myfree(ht->hashhashvalues);
|
||||
free(ht->hashhashvalues);
|
||||
ht->hashhashvalues = NULL;
|
||||
}
|
||||
ht->poolsize = 0;
|
||||
@ -71,13 +71,13 @@ int inithashtable(struct hashtable *ht, unsigned tablesize, unsigned poolsize, u
|
||||
_3proxy_mutex_init(&ht->hash_mutex);
|
||||
_3proxy_mutex_lock(&ht->hash_mutex);
|
||||
}
|
||||
if(!(ht->ihashtable = myalloc(tablesize * sizeof(uint32_t)))
|
||||
|| !(ht->hashvalues = myalloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
|
||||
|| !(ht->hashhashvalues = myalloc(poolsize * ht->hash_size))
|
||||
if(!(ht->ihashtable = malloc(tablesize * sizeof(uint32_t)))
|
||||
|| !(ht->hashvalues = malloc(poolsize * (sizeof(struct hashentry) + ht->recsize - 4)))
|
||||
|| !(ht->hashhashvalues = malloc(poolsize * ht->hash_size))
|
||||
){
|
||||
myfree(ht->ihashtable);
|
||||
free(ht->ihashtable);
|
||||
ht->ihashtable = NULL;
|
||||
myfree(ht->hashvalues);
|
||||
free(ht->hashvalues);
|
||||
ht->hashvalues = NULL;
|
||||
_3proxy_mutex_unlock(&ht->hash_mutex);
|
||||
return 3;
|
||||
@ -127,10 +127,10 @@ static void hashgrow(struct hashtable *ht){
|
||||
if(ht->ihashempty) return;
|
||||
if(ht->poolsize >= ht->growlimit) return;
|
||||
if(newsize > ht->growlimit) newsize = ht->growlimit;
|
||||
newvalues = myrealloc(ht->hashvalues, newsize * (sizeof(struct hashentry) + ht->recsize - 4));
|
||||
newvalues = realloc(ht->hashvalues, newsize * (sizeof(struct hashentry) + ht->recsize - 4));
|
||||
if(!newvalues) return;
|
||||
ht->hashvalues = newvalues;
|
||||
newvalues = myrealloc(ht->hashhashvalues, newsize * ht->hash_size);
|
||||
newvalues = realloc(ht->hashhashvalues, newsize * ht->hash_size);
|
||||
if(!newvalues) return;
|
||||
ht->hashhashvalues = newvalues;
|
||||
memset(ht->hashvalues + (ht->poolsize * (sizeof(struct hashentry) + ht->recsize - 4)), 0, (newsize - ht->poolsize) * (sizeof(struct hashentry) + ht->recsize - 4));
|
||||
@ -142,7 +142,7 @@ static void hashgrow(struct hashtable *ht){
|
||||
ht->poolsize = newsize;
|
||||
if (ht->poolsize / ht->tablesize > 10) {
|
||||
unsigned newtablesize = ht->poolsize / 3;
|
||||
uint32_t *newitable = myalloc(newtablesize * sizeof(uint32_t));
|
||||
uint32_t *newitable = malloc(newtablesize * sizeof(uint32_t));
|
||||
if (newitable) {
|
||||
unsigned j;
|
||||
memset(newitable, 0, newtablesize * sizeof(uint32_t));
|
||||
@ -156,7 +156,7 @@ static void hashgrow(struct hashtable *ht){
|
||||
he = next;
|
||||
}
|
||||
}
|
||||
myfree(ht->ihashtable);
|
||||
free(ht->ihashtable);
|
||||
ht->ihashtable = newitable;
|
||||
ht->tablesize = newtablesize;
|
||||
}
|
||||
|
||||
@ -112,10 +112,10 @@ struct pluginlink pluginlink = {
|
||||
decodeurl,
|
||||
parsestr,
|
||||
make_ace,
|
||||
myalloc,
|
||||
myfree,
|
||||
myrealloc,
|
||||
mystrdup,
|
||||
malloc,
|
||||
free,
|
||||
realloc,
|
||||
strdup,
|
||||
trafcountfunc,
|
||||
proxy_stringtable,
|
||||
&schedule,
|
||||
|
||||
56
src/proxy.c
56
src/proxy.c
@ -239,7 +239,7 @@ void * proxychild(struct clientparam* param) {
|
||||
|
||||
|
||||
if(param->remsock != INVALID_SOCKET) haveconnection = 1;
|
||||
if(!(buf = myalloc(BUFSIZE))) {RETURN(21);}
|
||||
if(!(buf = malloc(BUFSIZE))) {RETURN(21);}
|
||||
bufsize = BUFSIZE;
|
||||
anonymous = param->srv->anonymous;
|
||||
for(;;){
|
||||
@ -292,9 +292,9 @@ for(;;){
|
||||
memset(¶m->sinsr, 0, sizeof(param->sinsr));
|
||||
memset(¶m->req, 0, sizeof(param->req));
|
||||
}
|
||||
myfree(req);
|
||||
free(req);
|
||||
}
|
||||
req = (unsigned char *)mystrdup((char *)buf);
|
||||
req = (unsigned char *)strdup((char *)buf);
|
||||
if(!req){RETURN(510);}
|
||||
if(i<10) {
|
||||
RETURN(511);
|
||||
@ -335,13 +335,13 @@ for(;;){
|
||||
prefix = (int)(se - buf);
|
||||
su = (unsigned char*)strrchr((char *)sb, '@');
|
||||
if(su) {
|
||||
su = (unsigned char *)mystrdup((char *)sb);
|
||||
su = (unsigned char *)strdup((char *)sb);
|
||||
decodeurl(su, 0);
|
||||
if(parseconnusername((char *)su, (struct clientparam *)param, 1, (uint16_t)((ftp)?21:80))) {
|
||||
myfree(su);
|
||||
free(su);
|
||||
RETURN (100);
|
||||
}
|
||||
myfree(su);
|
||||
free(su);
|
||||
}
|
||||
else if(parsehostname((char *)sb, (struct clientparam *)param, (uint16_t)((ftp)? 21:80))) RETURN(100);
|
||||
if(!isconnect){
|
||||
@ -376,12 +376,12 @@ for(;;){
|
||||
sb = (unsigned char *)strchr((char *)username, ':');
|
||||
if(sb){
|
||||
*sb = 0;
|
||||
if(param->password)myfree(param->password);
|
||||
param->password = (unsigned char *)mystrdup((char *)sb+1);
|
||||
if(param->password)free(param->password);
|
||||
param->password = (unsigned char *)strdup((char *)sb+1);
|
||||
param->pwtype = 0;
|
||||
}
|
||||
if(param->username)myfree(param->username);
|
||||
param->username = (unsigned char *)mystrdup((char *)username);
|
||||
if(param->username)free(param->username);
|
||||
param->username = (unsigned char *)strdup((char *)username);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -420,12 +420,12 @@ for(;;){
|
||||
if(!param->hostname){
|
||||
if(parsehostname((char *)sb, param, 80)) RETURN(100);
|
||||
}
|
||||
newbuf = myalloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8);
|
||||
newbuf = malloc(strlen((char *)req) + strlen((char *)(buf+inbuf)) + 8);
|
||||
if(newbuf){
|
||||
sp = (unsigned char *)strchr((char *)req+1, '/');
|
||||
memcpy(newbuf, req, (sp - req));
|
||||
sprintf((char*)newbuf + (sp - req), "http://%s%s",sb,sp);
|
||||
myfree(req);
|
||||
free(req);
|
||||
req = newbuf;
|
||||
}
|
||||
if(se)*se = c;
|
||||
@ -445,11 +445,11 @@ for(;;){
|
||||
sb = (unsigned char *)strchr((char *)username, ':');
|
||||
if(sb){
|
||||
*sb = 0;
|
||||
if(param->extpassword)myfree(param->extpassword);
|
||||
param->extpassword = (unsigned char *)mystrdup((char *)sb+1);
|
||||
if(param->extpassword)free(param->extpassword);
|
||||
param->extpassword = (unsigned char *)strdup((char *)sb+1);
|
||||
}
|
||||
if(param->extusername)myfree(param->extusername);
|
||||
param->extusername = (unsigned char *)mystrdup((char *)username);
|
||||
if(param->extusername)free(param->extusername);
|
||||
param->extusername = (unsigned char *)strdup((char *)username);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
@ -469,7 +469,7 @@ for(;;){
|
||||
if (bufsize > (LINESIZE * 16)){
|
||||
RETURN (516);
|
||||
}
|
||||
if(!(newbuf = myrealloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||
if(!(newbuf = realloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||
buf = newbuf;
|
||||
bufsize += BUFSIZE;
|
||||
}
|
||||
@ -560,14 +560,14 @@ for(;;){
|
||||
}
|
||||
}
|
||||
ckeepalive = 1;
|
||||
if(ftpbase) myfree(ftpbase);
|
||||
if(ftpbase) free(ftpbase);
|
||||
ftpbase = NULL;
|
||||
if(!(sp = (unsigned char *)strchr((char *)ss, ' '))){RETURN(799);}
|
||||
*sp = 0;
|
||||
|
||||
decodeurl(ss, 0);
|
||||
i = (int)strlen((char *)ss);
|
||||
if(!(ftpbase = myalloc(i+2))){RETURN(21);}
|
||||
if(!(ftpbase = malloc(i+2))){RETURN(21);}
|
||||
memcpy(ftpbase, ss, i);
|
||||
if(ftpbase[i-1] != '/') ftpbase[i++] = '/';
|
||||
ftpbase[i] = 0;
|
||||
@ -757,7 +757,7 @@ for(;;){
|
||||
inbuf = 0;
|
||||
}
|
||||
else {
|
||||
if(!(newbuf = myrealloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||
if(!(newbuf = realloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||
buf = newbuf;
|
||||
bufsize += BUFSIZE;
|
||||
}
|
||||
@ -793,14 +793,14 @@ for(;;){
|
||||
|
||||
if(isconnect && param->redirtype != R_HTTP) {
|
||||
if(param->redirectfunc) {
|
||||
if(req)myfree(req);
|
||||
if(buf)myfree(buf);
|
||||
if(req)free(req);
|
||||
if(buf)free(buf);
|
||||
return (*param->redirectfunc)(param);
|
||||
}
|
||||
param->res = mapsocket(param, conf.timeouts[CONNECTION_L]);
|
||||
if(param->redirectfunc) {
|
||||
if(req)myfree(req);
|
||||
if(buf)myfree(buf);
|
||||
if(req)free(req);
|
||||
if(buf)free(buf);
|
||||
return (*param->redirectfunc)(param);
|
||||
}
|
||||
RETURN(param->res);
|
||||
@ -939,7 +939,7 @@ for(;;){
|
||||
if (bufsize > 20000){
|
||||
RETURN (516);
|
||||
}
|
||||
if(!(newbuf = myrealloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||
if(!(newbuf = realloc(buf, bufsize + BUFSIZE))){RETURN (21);}
|
||||
buf = newbuf;
|
||||
bufsize += BUFSIZE;
|
||||
}
|
||||
@ -1122,9 +1122,9 @@ CLEANRET:
|
||||
}
|
||||
}
|
||||
logurl(param, (char *)buf, (char *)req, ftp);
|
||||
if(req)myfree(req);
|
||||
if(buf)myfree(buf);
|
||||
if(ftpbase)myfree(ftpbase);
|
||||
if(req)free(req);
|
||||
if(buf)free(buf);
|
||||
if(ftpbase)free(ftpbase);
|
||||
freeparam(param);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -148,10 +148,6 @@ void daemonize(void);
|
||||
|
||||
#define DEFLOGFORMAT "G%y%m%d%H%M%S.%. %p %E %U %C:%c %R:%r %O %I %h %T"
|
||||
|
||||
#define myalloc malloc
|
||||
#define myfree free
|
||||
#define myrealloc realloc
|
||||
#define mystrdup strdup
|
||||
|
||||
#ifdef _TIME64_T_DEFINED
|
||||
#ifdef _MAX__TIME64_T
|
||||
|
||||
156
src/proxymain.c
156
src/proxymain.c
@ -204,17 +204,17 @@ void setopts(SOCKET s, int opts){
|
||||
}
|
||||
|
||||
static void freesrvstrings(struct srvparam *srv, unsigned char *cbc_string, unsigned char *cbl_string) {
|
||||
if(cbc_string) myfree(cbc_string);
|
||||
if(cbl_string) myfree(cbl_string);
|
||||
if(srv->logtarget) myfree(srv->logtarget);
|
||||
if(srv->logformat) myfree(srv->logformat);
|
||||
if(cbc_string) free(cbc_string);
|
||||
if(cbl_string) free(cbl_string);
|
||||
if(srv->logtarget) free(srv->logtarget);
|
||||
if(srv->logformat) free(srv->logformat);
|
||||
#if defined SO_BINDTODEVICE || defined IP_BOUND_IF
|
||||
if(srv->ibindtodevice) myfree(srv->ibindtodevice);
|
||||
if(srv->obindtodevice) myfree(srv->obindtodevice);
|
||||
if(srv->ibindtodevice) free(srv->ibindtodevice);
|
||||
if(srv->obindtodevice) free(srv->obindtodevice);
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
if(srv->inetns) myfree(srv->inetns);
|
||||
if(srv->onetns) myfree(srv->onetns);
|
||||
if(srv->inetns) free(srv->inetns);
|
||||
if(srv->onetns) free(srv->onetns);
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -391,14 +391,14 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
break;
|
||||
#if defined SO_BINDTODEVICE || defined IP_BOUND_IF
|
||||
case 'D':
|
||||
if(argv[i][2] == 'i') srv.ibindtodevice = mystrdup(argv[i] + 3);
|
||||
else srv.obindtodevice = mystrdup(argv[i] + 3);
|
||||
if(argv[i][2] == 'i') srv.ibindtodevice = strdup(argv[i] + 3);
|
||||
else srv.obindtodevice = strdup(argv[i] + 3);
|
||||
break;
|
||||
#endif
|
||||
case 'l':
|
||||
srv.logfunc = logstdout;
|
||||
if(srv.logtarget) myfree(srv.logtarget);
|
||||
srv.logtarget = (unsigned char *)mystrdup(argv[i] + 2);
|
||||
if(srv.logtarget) free(srv.logtarget);
|
||||
srv.logtarget = (unsigned char *)strdup(argv[i] + 2);
|
||||
if(argv[i][2]) {
|
||||
if(argv[i][2]=='@'){
|
||||
|
||||
@ -450,8 +450,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
break;
|
||||
#ifdef __linux__
|
||||
case 'n':
|
||||
if(argv[i][2] == 'i') { if(srv.inetns) myfree(srv.inetns); srv.inetns = mystrdup(argv[i] + 3); }
|
||||
else if(argv[i][2] == 'e') { if(srv.onetns) myfree(srv.onetns); srv.onetns = mystrdup(argv[i] + 3); }
|
||||
if(argv[i][2] == 'i') { if(srv.inetns) free(srv.inetns); srv.inetns = strdup(argv[i] + 3); }
|
||||
else if(argv[i][2] == 'e') { if(srv.onetns) free(srv.onetns); srv.onetns = strdup(argv[i] + 3); }
|
||||
break;
|
||||
#endif
|
||||
case 'p':
|
||||
@ -479,8 +479,8 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
#endif
|
||||
#endif
|
||||
case 'f':
|
||||
if(srv.logformat)myfree(srv.logformat);
|
||||
srv.logformat = (unsigned char *)mystrdup(argv[i] + 2);
|
||||
if(srv.logformat)free(srv.logformat);
|
||||
srv.logformat = (unsigned char *)strdup(argv[i] + 2);
|
||||
break;
|
||||
case 't':
|
||||
srv.silent = 1;
|
||||
@ -496,11 +496,11 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
if(isdigit(argv[i][2])) srv.requirecert = atoi(argv[i]+2);
|
||||
break;
|
||||
case 'r':
|
||||
cbc_string = (unsigned char *)mystrdup(argv[i] + 2);
|
||||
cbc_string = (unsigned char *)strdup(argv[i] + 2);
|
||||
iscbc = 1;
|
||||
break;
|
||||
case 'R':
|
||||
cbl_string = (unsigned char *)mystrdup(argv[i] + 2);
|
||||
cbl_string = (unsigned char *)strdup(argv[i] + 2);
|
||||
iscbl = 1;
|
||||
break;
|
||||
case 'u':
|
||||
@ -621,7 +621,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
);
|
||||
return (1);
|
||||
}
|
||||
srv.target = (unsigned char *)mystrdup(argv[i+1]);
|
||||
srv.target = (unsigned char *)strdup(argv[i+1]);
|
||||
#endif
|
||||
#ifndef STDMAIN
|
||||
}
|
||||
@ -638,7 +638,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
srv.so._setsockopt(srv.so.state, 0, SOL_SOCKET, SO_OOBINLINE, (unsigned char *)&opt, sizeof(int));
|
||||
}
|
||||
defparam.clisock = 0;
|
||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||
if(! (newparam = malloc (sizeof(defparam)))){
|
||||
return 2;
|
||||
};
|
||||
*newparam = defparam;
|
||||
@ -1011,7 +1011,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
}
|
||||
}
|
||||
#endif
|
||||
if(! (newparam = myalloc (sizeof(defparam)))){
|
||||
if(! (newparam = malloc (sizeof(defparam)))){
|
||||
if(!isudp) srv.so._closesocket(srv.so.state, new_sock);
|
||||
#ifndef NOUDPMAIN
|
||||
else {
|
||||
@ -1024,7 +1024,7 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
continue;
|
||||
};
|
||||
*newparam = defparam;
|
||||
if(defparam.hostname)newparam->hostname=(unsigned char *)mystrdup((char *)defparam.hostname);
|
||||
if(defparam.hostname)newparam->hostname=(unsigned char *)strdup((char *)defparam.hostname);
|
||||
clearstat(newparam);
|
||||
if(!isudp) newparam->clisock = new_sock;
|
||||
#ifndef STDMAIN
|
||||
@ -1104,9 +1104,9 @@ int MODULEMAINFUNC (int argc, char** argv){
|
||||
#ifndef _WIN32
|
||||
pthread_attr_destroy(&pa);
|
||||
#endif
|
||||
if(defparam.hostname)myfree(defparam.hostname);
|
||||
if(cbc_string)myfree(cbc_string);
|
||||
if(cbl_string)myfree(cbl_string);
|
||||
if(defparam.hostname)free(defparam.hostname);
|
||||
if(cbc_string)free(cbc_string);
|
||||
if(cbl_string)free(cbl_string);
|
||||
if(fp) fclose(fp);
|
||||
|
||||
return 0;
|
||||
@ -1129,14 +1129,14 @@ void srvinit(struct srvparam * srv, struct clientparam *param){
|
||||
srv->paused = conf.paused;
|
||||
srv->logfunc = havelog?conf.logfunc:lognone;
|
||||
srv->noforce = conf.noforce;
|
||||
srv->logformat = conf.logformat? (unsigned char *)mystrdup((char *)conf.logformat) : NULL;
|
||||
srv->logformat = conf.logformat? (unsigned char *)strdup((char *)conf.logformat) : NULL;
|
||||
srv->authfunc = conf.authfunc;
|
||||
srv->maxchild = conf.maxchild;
|
||||
srv->backlog = conf.backlog;
|
||||
srv->stacksize = conf.stacksize;
|
||||
srv->time_start = time(NULL);
|
||||
if(havelog && conf.logtarget){
|
||||
srv->logtarget = (unsigned char *)mystrdup((char *)conf.logtarget);
|
||||
srv->logtarget = (unsigned char *)strdup((char *)conf.logtarget);
|
||||
}
|
||||
srv->srvsock = INVALID_SOCKET;
|
||||
srv->logdumpsrv = conf.logdumpsrv;
|
||||
@ -1180,11 +1180,11 @@ void srvinit2(struct srvparam * srv, struct clientparam *param){
|
||||
unsigned char* logformat = srv->logformat;
|
||||
|
||||
*s = 0;
|
||||
srv->nonprintable = (unsigned char *)mystrdup((char *)srv->logformat + 1);
|
||||
srv->nonprintable = (unsigned char *)strdup((char *)srv->logformat + 1);
|
||||
srv->replace = s[1];
|
||||
srv->logformat = (unsigned char *)mystrdup(s + 2);
|
||||
srv->logformat = (unsigned char *)strdup(s + 2);
|
||||
*s = '+';
|
||||
myfree(logformat);
|
||||
free(logformat);
|
||||
}
|
||||
}
|
||||
memset(¶m->sinsl, 0, sizeof(param->sinsl));
|
||||
@ -1221,24 +1221,24 @@ void srvfree(struct srvparam * srv){
|
||||
(*srv->filter[srv->nfilters].filter_close)(srv->filter[srv->nfilters].data);
|
||||
}
|
||||
}
|
||||
myfree(srv->filter);
|
||||
free(srv->filter);
|
||||
}
|
||||
|
||||
if(srv->acl)freeacl(srv->acl);
|
||||
if(srv->authfuncs)freeauth(srv->authfuncs);
|
||||
#endif
|
||||
_3proxy_mutex_destroy(&srv->counter_mutex);
|
||||
if(srv->target) myfree(srv->target);
|
||||
if(srv->logtarget) myfree(srv->logtarget);
|
||||
if(srv->logformat) myfree(srv->logformat);
|
||||
if(srv->nonprintable) myfree(srv->nonprintable);
|
||||
if(srv->target) free(srv->target);
|
||||
if(srv->logtarget) free(srv->logtarget);
|
||||
if(srv->logformat) free(srv->logformat);
|
||||
if(srv->nonprintable) free(srv->nonprintable);
|
||||
#if defined SO_BINDTODEVICE || defined IP_BOUND_IF
|
||||
if(srv->ibindtodevice) myfree(srv->ibindtodevice);
|
||||
if(srv->obindtodevice) myfree(srv->obindtodevice);
|
||||
if(srv->ibindtodevice) free(srv->ibindtodevice);
|
||||
if(srv->obindtodevice) free(srv->obindtodevice);
|
||||
#endif
|
||||
#ifdef __linux__
|
||||
if(srv->inetns) myfree(srv->inetns);
|
||||
if(srv->onetns) myfree(srv->onetns);
|
||||
if(srv->inetns) free(srv->inetns);
|
||||
if(srv->onetns) free(srv->onetns);
|
||||
#endif
|
||||
if(srv->so.freefunc) srv->so.freefunc(srv->so.state);
|
||||
}
|
||||
@ -1263,8 +1263,8 @@ void freeparam(struct clientparam * param) {
|
||||
(param->srv->childcount)--;
|
||||
_3proxy_mutex_unlock(¶m->srv->counter_mutex);
|
||||
}
|
||||
if(param->clibuf) myfree(param->clibuf);
|
||||
if(param->srvbuf) myfree(param->srvbuf);
|
||||
if(param->clibuf) free(param->clibuf);
|
||||
if(param->srvbuf) free(param->srvbuf);
|
||||
if(param->srv) {
|
||||
if(param->ctrlsocksrv != INVALID_SOCKET && param->ctrlsocksrv != param->remsock) {
|
||||
param->srv->so._shutdown(param->sostate, param->ctrlsocksrv, SHUT_RDWR);
|
||||
@ -1283,30 +1283,30 @@ void freeparam(struct clientparam * param) {
|
||||
param->srv->so._closesocket(param->sostate, param->clisock);
|
||||
}
|
||||
}
|
||||
if(param->datfilterssrv) myfree(param->datfilterssrv);
|
||||
if(param->datfilterssrv) free(param->datfilterssrv);
|
||||
#ifndef STDMAIN
|
||||
if(param->reqfilters) myfree(param->reqfilters);
|
||||
if(param->connectfilters) myfree(param->connectfilters);
|
||||
if(param->afterauthfilters) myfree(param->afterauthfilters);
|
||||
if(param->hdrfilterscli) myfree(param->hdrfilterscli);
|
||||
if(param->hdrfilterssrv) myfree(param->hdrfilterssrv);
|
||||
if(param->predatfilters) myfree(param->predatfilters);
|
||||
if(param->datfilterscli) myfree(param->datfilterscli);
|
||||
if(param->reqfilters) free(param->reqfilters);
|
||||
if(param->connectfilters) free(param->connectfilters);
|
||||
if(param->afterauthfilters) free(param->afterauthfilters);
|
||||
if(param->hdrfilterscli) free(param->hdrfilterscli);
|
||||
if(param->hdrfilterssrv) free(param->hdrfilterssrv);
|
||||
if(param->predatfilters) free(param->predatfilters);
|
||||
if(param->datfilterscli) free(param->datfilterscli);
|
||||
if(param->filters){
|
||||
if(param->nfilters)while(param->nfilters--){
|
||||
if(param->filters[param->nfilters].filter->filter_clear)
|
||||
(*param->filters[param->nfilters].filter->filter_clear)(param->filters[param->nfilters].data);
|
||||
}
|
||||
myfree(param->filters);
|
||||
free(param->filters);
|
||||
}
|
||||
if(param->connlim) stopconnlims(param);
|
||||
#endif
|
||||
if(param->hostname) myfree(param->hostname);
|
||||
if(param->username) myfree(param->username);
|
||||
if(param->password) myfree(param->password);
|
||||
if(param->extusername) myfree(param->extusername);
|
||||
if(param->extpassword) myfree(param->extpassword);
|
||||
myfree(param);
|
||||
if(param->hostname) free(param->hostname);
|
||||
if(param->username) free(param->username);
|
||||
if(param->password) free(param->password);
|
||||
if(param->extusername) free(param->extusername);
|
||||
if(param->extpassword) free(param->extpassword);
|
||||
free(param);
|
||||
}
|
||||
|
||||
FILTER_ACTION handleconnectflt(struct clientparam *cparam){
|
||||
@ -1327,7 +1327,7 @@ FILTER_ACTION handleconnectflt(struct clientparam *cparam){
|
||||
static void * itcopy (void * from, size_t size){
|
||||
void * ret;
|
||||
if(!from) return NULL;
|
||||
ret = myalloc(size);
|
||||
ret = malloc(size);
|
||||
if(ret) memcpy(ret, from, size);
|
||||
return ret;
|
||||
}
|
||||
@ -1398,7 +1398,7 @@ struct ace * copyacl (struct ace *ac){
|
||||
if(!ac->users) goto ERRORUSERS;
|
||||
for(ul = ac->users; ul; ul = ul->next){
|
||||
if(ul->user) {
|
||||
ul->user = (unsigned char*)mystrdup((char *)ul->user);
|
||||
ul->user = (unsigned char*)strdup((char *)ul->user);
|
||||
if(!ul->user) {
|
||||
ul->next = NULL;
|
||||
goto ERRORUSERS;
|
||||
@ -1415,7 +1415,7 @@ struct ace * copyacl (struct ace *ac){
|
||||
if(!ac->dstnames) goto ERRORDSTNAMES;
|
||||
for(hst = ac->dstnames; hst; hst = hst->next){
|
||||
if(hst->name) {
|
||||
hst->name = (unsigned char*)mystrdup((char *)hst->name);
|
||||
hst->name = (unsigned char*)strdup((char *)hst->name);
|
||||
if(!hst->name) {
|
||||
hst->next = NULL;
|
||||
goto ERRORDSTNAMES;
|
||||
@ -1432,7 +1432,7 @@ struct ace * copyacl (struct ace *ac){
|
||||
if(!ac->chains) goto ERRORCHAINS;
|
||||
for(ch = ac->chains; ch; ch = ch->next){
|
||||
if(ch->extuser){
|
||||
ch->extuser = (unsigned char*)mystrdup((char *)ch->extuser);
|
||||
ch->extuser = (unsigned char*)strdup((char *)ch->extuser);
|
||||
if(!ch->extuser){
|
||||
ch->extpass = NULL;
|
||||
ch->exthost = NULL;
|
||||
@ -1441,7 +1441,7 @@ struct ace * copyacl (struct ace *ac){
|
||||
}
|
||||
}
|
||||
if(ch->extpass){
|
||||
ch->extpass = (unsigned char*)mystrdup((char *)ch->extpass);
|
||||
ch->extpass = (unsigned char*)strdup((char *)ch->extpass);
|
||||
if(!ch->extpass){
|
||||
ch->exthost = NULL;
|
||||
ch->next = NULL;
|
||||
@ -1449,7 +1449,7 @@ struct ace * copyacl (struct ace *ac){
|
||||
}
|
||||
}
|
||||
if(ch->exthost){
|
||||
ch->exthost = (unsigned char*)mystrdup((char *)ch->exthost);
|
||||
ch->exthost = (unsigned char*)strdup((char *)ch->exthost);
|
||||
if(!ch->exthost){
|
||||
ch->next = NULL;
|
||||
goto ERRORCHAINS;
|
||||
@ -1494,7 +1494,7 @@ void copyfilter (struct filter *filter, struct srvparam *srv){
|
||||
|
||||
if(!filter) return;
|
||||
for(srv->filter = filter; srv->filter; srv->filter = srv->filter->next) nfilters++;
|
||||
srv->filter = myalloc(sizeof(struct filter) * nfilters);
|
||||
srv->filter = malloc(sizeof(struct filter) * nfilters);
|
||||
if(!srv->filter) return;
|
||||
|
||||
for(; filter; filter = filter->next){
|
||||
@ -1524,15 +1524,15 @@ FILTER_ACTION makefilters (struct srvparam *srv, struct clientparam *param){
|
||||
|
||||
if(!srv->nfilters) return PASS;
|
||||
|
||||
if(!(param->filters = myalloc(sizeof(struct filterp) * srv->nfilters)) ||
|
||||
(srv->nreqfilters && !(param->reqfilters = myalloc(sizeof(struct filterp *) * srv->nreqfilters))) ||
|
||||
(srv->nconnectfilters && !(param->connectfilters = myalloc(sizeof(struct filterp *) * srv->nconnectfilters))) ||
|
||||
(srv->nafterauthfilters && !(param->afterauthfilters = myalloc(sizeof(struct filterp *) * srv->nafterauthfilters))) ||
|
||||
(srv->nhdrfilterssrv && !(param->hdrfilterssrv = myalloc(sizeof(struct filterp *) * srv->nhdrfilterssrv))) ||
|
||||
(srv->nhdrfilterscli && !(param->hdrfilterscli = myalloc(sizeof(struct filterp *) * srv->nhdrfilterscli))) ||
|
||||
(srv->npredatfilters && !(param->predatfilters = myalloc(sizeof(struct filterp *) * srv->npredatfilters))) ||
|
||||
(srv->ndatfilterssrv && !(param->datfilterssrv = myalloc(sizeof(struct filterp *) * srv->ndatfilterssrv))) ||
|
||||
(srv->ndatfilterscli && !(param->datfilterscli = myalloc(sizeof(struct filterp *) * srv->ndatfilterscli)))
|
||||
if(!(param->filters = malloc(sizeof(struct filterp) * srv->nfilters)) ||
|
||||
(srv->nreqfilters && !(param->reqfilters = malloc(sizeof(struct filterp *) * srv->nreqfilters))) ||
|
||||
(srv->nconnectfilters && !(param->connectfilters = malloc(sizeof(struct filterp *) * srv->nconnectfilters))) ||
|
||||
(srv->nafterauthfilters && !(param->afterauthfilters = malloc(sizeof(struct filterp *) * srv->nafterauthfilters))) ||
|
||||
(srv->nhdrfilterssrv && !(param->hdrfilterssrv = malloc(sizeof(struct filterp *) * srv->nhdrfilterssrv))) ||
|
||||
(srv->nhdrfilterscli && !(param->hdrfilterscli = malloc(sizeof(struct filterp *) * srv->nhdrfilterscli))) ||
|
||||
(srv->npredatfilters && !(param->predatfilters = malloc(sizeof(struct filterp *) * srv->npredatfilters))) ||
|
||||
(srv->ndatfilterssrv && !(param->datfilterssrv = malloc(sizeof(struct filterp *) * srv->ndatfilterssrv))) ||
|
||||
(srv->ndatfilterscli && !(param->datfilterscli = malloc(sizeof(struct filterp *) * srv->ndatfilterscli)))
|
||||
){
|
||||
param->res = 21;
|
||||
return REJECT;
|
||||
@ -1558,7 +1558,7 @@ FILTER_ACTION makefilters (struct srvparam *srv, struct clientparam *param){
|
||||
}
|
||||
|
||||
void * itfree(void *data, void * retval){
|
||||
myfree(data);
|
||||
free(data);
|
||||
return retval;
|
||||
}
|
||||
|
||||
@ -1579,15 +1579,15 @@ void freeacl(struct ace *ac){
|
||||
for(pl = ac->ports; pl; pl = (struct portlist *)itfree(pl, pl->next));
|
||||
for(pel = ac->periods; pel; pel = (struct period *)itfree(pel, pel->next));
|
||||
for(ul = ac->users; ul; ul = (struct userlist *)itfree(ul, ul->next)){
|
||||
if(ul->user)myfree(ul->user);
|
||||
if(ul->user)free(ul->user);
|
||||
}
|
||||
for(hst = ac->dstnames; hst; hst = (struct hostname *)itfree(hst, hst->next)){
|
||||
if(hst->name)myfree(hst->name);
|
||||
if(hst->name)free(hst->name);
|
||||
}
|
||||
for(ch = ac->chains; ch; ch = (struct chain *) itfree(ch, ch->next)){
|
||||
if(ch->extuser) myfree(ch->extuser);
|
||||
if(ch->extpass) myfree(ch->extpass);
|
||||
if(ch->exthost) myfree(ch->exthost);
|
||||
if(ch->extuser) free(ch->extuser);
|
||||
if(ch->extpass) free(ch->extpass);
|
||||
if(ch->exthost) free(ch->exthost);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -28,7 +28,7 @@ int clientnegotiate(struct chain * redir, struct clientparam * param, struct soc
|
||||
pass = redir->extpass;
|
||||
if (!param->srvbufsize){
|
||||
param->srvbufsize = SRVBUFSIZE;
|
||||
param->srvbuf = myalloc(param->srvbufsize);
|
||||
param->srvbuf = malloc(param->srvbufsize);
|
||||
if(!param->srvbuf) return 21;
|
||||
}
|
||||
buf = param->srvbuf;
|
||||
@ -322,12 +322,12 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
int i;
|
||||
if(cur->extuser){
|
||||
if(param->extusername)
|
||||
myfree(param->extusername);
|
||||
param->extusername = (unsigned char *)mystrdup((char *)((*cur->extuser == '*' && param->username)? param->username : cur->extuser));
|
||||
free(param->extusername);
|
||||
param->extusername = (unsigned char *)strdup((char *)((*cur->extuser == '*' && param->username)? param->username : cur->extuser));
|
||||
if(cur->extpass){
|
||||
if(param->extpassword)
|
||||
myfree(param->extpassword);
|
||||
param->extpassword = (unsigned char *)mystrdup((char *)((*cur->extuser == '*' && param->password)?param->password : cur->extpass));
|
||||
free(param->extpassword);
|
||||
param->extpassword = (unsigned char *)strdup((char *)((*cur->extuser == '*' && param->password)?param->password : cur->extpass));
|
||||
}
|
||||
if(*cur->extuser == '*' && !param->username) return 4;
|
||||
}
|
||||
@ -389,12 +389,12 @@ int handleredirect(struct clientparam * param, struct ace * acentry){
|
||||
if(cur->extuser){
|
||||
if(*cur -> extuser == '*' && !param->username) return 4;
|
||||
if(param->extusername)
|
||||
myfree(param->extusername);
|
||||
param->extusername = (unsigned char *)mystrdup((char *)((*cur->extuser == '*' && param->username)? param->username : cur->extuser));
|
||||
free(param->extusername);
|
||||
param->extusername = (unsigned char *)strdup((char *)((*cur->extuser == '*' && param->username)? param->username : cur->extuser));
|
||||
if(cur->extpass){
|
||||
if(param->extpassword)
|
||||
myfree(param->extpassword);
|
||||
param->extpassword = (unsigned char *)mystrdup((char *)((*cur->extuser == '*' && param->password)?param->password : cur->extpass));
|
||||
free(param->extpassword);
|
||||
param->extpassword = (unsigned char *)strdup((char *)((*cur->extuser == '*' && param->password)?param->password : cur->extpass));
|
||||
}
|
||||
}
|
||||
if(redir->secure) return ssl_parent(param);
|
||||
|
||||
@ -171,8 +171,8 @@ uint32_t udpresolve(int af, unsigned char * name, unsigned char * value, uint32_
|
||||
s2 = s1;
|
||||
}
|
||||
*s2 = 0;
|
||||
if(param->username)myfree(param->username);
|
||||
param->username = (unsigned char *)mystrdup ((char *)buf + k + 13);
|
||||
if(param->username)free(param->username);
|
||||
param->username = (unsigned char *)strdup ((char *)buf + k + 13);
|
||||
|
||||
return udpresolve(af,param->username, value, NULL, NULL, 2);
|
||||
}
|
||||
|
||||
34
src/smtpp.c
34
src/smtpp.c
@ -19,26 +19,26 @@ int readreply (struct clientparam* param) {
|
||||
unsigned char * buf;
|
||||
int res, i, bufsize = 640;
|
||||
|
||||
if(!(buf = myalloc(bufsize))) return 0;
|
||||
if(!(buf = malloc(bufsize))) return 0;
|
||||
do {
|
||||
i = sockgetlinebuf(param, SERVER, buf, bufsize-1, '\n', conf.timeouts[STRING_L]);
|
||||
if(i < 1) break;
|
||||
#ifndef WITHMAIN
|
||||
res = handlehdrfilterssrv(param, &buf, &bufsize, 0, &i);
|
||||
if(res != PASS) {
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
return -1;
|
||||
}
|
||||
#endif
|
||||
socksend(param, param->clisock, buf, i, conf.timeouts[STRING_S]);
|
||||
} while (i > 3 && buf[3] == '-');
|
||||
if(i < 3) {
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
buf[i] = 0;
|
||||
res = atoi((char *)buf);
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
return res;
|
||||
}
|
||||
|
||||
@ -47,14 +47,14 @@ int readcommand (struct clientparam* param) {
|
||||
int res, i, bufsize = 320;
|
||||
int ret = 1;
|
||||
|
||||
if(!(buf = myalloc(bufsize))) return 0;
|
||||
if(!(buf = malloc(bufsize))) return 0;
|
||||
i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L]);
|
||||
if(i < 4) return 0;
|
||||
#ifndef WITHMAIN
|
||||
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);
|
||||
if(res != PASS) {
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
if(res == HANDLED) return 2;
|
||||
return -1;
|
||||
}
|
||||
@ -64,7 +64,7 @@ int readcommand (struct clientparam* param) {
|
||||
if(!strncasecmp((char *)buf, "STARTTLS", 8) || !strncasecmp((char *)buf, "TURN", 4)){
|
||||
ret = 22;
|
||||
}
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -72,12 +72,12 @@ int readdata (struct clientparam* param) {
|
||||
unsigned char * buf;
|
||||
int res, i, bufsize = 4096;
|
||||
|
||||
if(!(buf = myalloc(bufsize))) return 0;
|
||||
if(!(buf = malloc(bufsize))) return 0;
|
||||
while ((i = sockgetlinebuf(param, CLIENT, buf, bufsize-1, '\n', conf.timeouts[STRING_L])) > 0 && !(i==3 && buf[0] == '.')){
|
||||
#ifndef WITHMAIN
|
||||
res = handledatfltcli(param, &buf, &bufsize, 0, &i);
|
||||
if(res != PASS) {
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
if(res == HANDLED) return 1;
|
||||
return -1;
|
||||
}
|
||||
@ -85,11 +85,11 @@ int readdata (struct clientparam* param) {
|
||||
socksend(param, param->remsock, buf, i, conf.timeouts[STRING_S]);
|
||||
}
|
||||
if(i < 1) {
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
return 0;
|
||||
}
|
||||
socksend(param, param->remsock, buf, i, conf.timeouts[STRING_S]);
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -118,7 +118,7 @@ void * smtppchild(struct clientparam* param) {
|
||||
else {
|
||||
login = -1;
|
||||
buf[i] = 0;
|
||||
command = mystrdup((char *)buf);
|
||||
command = strdup((char *)buf);
|
||||
break;
|
||||
}
|
||||
i = sockgetlinebuf(param, CLIENT, buf, sizeof(buf) - 10, '\n', conf.timeouts[STRING_S]);
|
||||
@ -140,8 +140,8 @@ void * smtppchild(struct clientparam* param) {
|
||||
i = de64(buf,username,255);
|
||||
if(i < 0) {RETURN(666);}
|
||||
username[i] = 0;
|
||||
if(param->extpassword) myfree(param->extpassword);
|
||||
param->extpassword = (unsigned char *)mystrdup((char *)username);
|
||||
if(param->extpassword) free(param->extpassword);
|
||||
param->extpassword = (unsigned char *)strdup((char *)username);
|
||||
}
|
||||
else if(login == 2){
|
||||
if(i > 13) {
|
||||
@ -160,8 +160,8 @@ void * smtppchild(struct clientparam* param) {
|
||||
parseconnusername((char *)username+1, param, 0, 25);
|
||||
res = (int)strlen((char *)username+1) + 2;
|
||||
if(res < i){
|
||||
if(param->extpassword) myfree(param->extpassword);
|
||||
param->extpassword = (unsigned char *)mystrdup((char *)username + res);
|
||||
if(param->extpassword) free(param->extpassword);
|
||||
param->extpassword = (unsigned char *)strdup((char *)username + res);
|
||||
}
|
||||
}
|
||||
|
||||
@ -298,7 +298,7 @@ CLEANRET:
|
||||
if(param->clisock != INVALID_SOCKET) {
|
||||
if ((param->res > 0 && param->res < 100) || (param->res > 661 && param->res <700)) socksend(param, param->clisock, (unsigned char *)"571 \r\n", 6,conf.timeouts[STRING_S]);
|
||||
}
|
||||
if(command) myfree(command);
|
||||
if(command) free(command);
|
||||
freeparam(param);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ int sockgetcharcli(struct clientparam * param, int timeosec, int timeousec){
|
||||
int len;
|
||||
|
||||
if(!param->clibuf){
|
||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return 0;
|
||||
if(!(param->clibuf = malloc(SRVBUFSIZE))) return 0;
|
||||
param->clibufsize = SRVBUFSIZE;
|
||||
param->clioffset = param->cliinbuf = 0;
|
||||
}
|
||||
@ -137,7 +137,7 @@ int sockgetcharsrv(struct clientparam * param, int timeosec, int timeousec){
|
||||
if(!param->srvbuf){
|
||||
bufsize = SRVBUFSIZE;
|
||||
if(param->ndatfilterssrv > 0 && bufsize < 32768) bufsize = 32768;
|
||||
if(!(param->srvbuf = myalloc(bufsize))) return 0;
|
||||
if(!(param->srvbuf = malloc(bufsize))) return 0;
|
||||
param->srvbufsize = bufsize;
|
||||
param->srvoffset = param->srvinbuf = 0;
|
||||
|
||||
|
||||
@ -103,10 +103,10 @@ int sockmap(struct clientparam * param, int timeo, int usesplice){
|
||||
if(!usesplice)
|
||||
#endif
|
||||
{
|
||||
if(fromserver && !param->srvbuf && (!(param->srvbuf=myalloc(SRVBUFSIZE)) || !(param->srvbufsize = SRVBUFSIZE))){
|
||||
if(fromserver && !param->srvbuf && (!(param->srvbuf=malloc(SRVBUFSIZE)) || !(param->srvbufsize = SRVBUFSIZE))){
|
||||
RETURN (21);
|
||||
}
|
||||
if(fromclient && !param->clibuf && (!(param->clibuf=myalloc(SRVBUFSIZE)) || !(param->clibufsize = SRVBUFSIZE))){
|
||||
if(fromclient && !param->clibuf && (!(param->clibuf=malloc(SRVBUFSIZE)) || !(param->clibufsize = SRVBUFSIZE))){
|
||||
RETURN (21);
|
||||
}
|
||||
|
||||
|
||||
20
src/socks.c
20
src/socks.c
@ -49,7 +49,7 @@ void * sockschild(struct clientparam* param) {
|
||||
|
||||
param->service = S_SOCKS;
|
||||
|
||||
if(!(buf = myalloc(BUFSIZE))) {RETURN(21);}
|
||||
if(!(buf = malloc(BUFSIZE))) {RETURN(21);}
|
||||
memset(buf, 0, BUFSIZE);
|
||||
if ((ver = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_L], 0)) != 5 && ver != 4) {
|
||||
RETURN(401);
|
||||
@ -74,11 +74,11 @@ void * sockschild(struct clientparam* param) {
|
||||
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(451);}
|
||||
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(441);};
|
||||
buf[i] = 0;
|
||||
if(!param->username)param->username = (unsigned char *)mystrdup((char *)buf);
|
||||
if(!param->username)param->username = (unsigned char *)strdup((char *)buf);
|
||||
if ((i = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(445);}
|
||||
if (i && (unsigned)(res = sockgetlinebuf(param, CLIENT, buf, i, 0, conf.timeouts[STRING_S])) != i){RETURN(441);};
|
||||
buf[i] = 0;
|
||||
if(!param->password)param->password = (unsigned char *)mystrdup((char *)buf);
|
||||
if(!param->password)param->password = (unsigned char *)strdup((char *)buf);
|
||||
buf[0] = 1;
|
||||
buf[1] = 0;
|
||||
if(socksend(param, param->clisock, buf, 2, conf.timeouts[STRING_S])!=2){RETURN(481);}
|
||||
@ -150,8 +150,8 @@ void * sockschild(struct clientparam* param) {
|
||||
default:
|
||||
RETURN(997);
|
||||
}
|
||||
if(param->hostname)myfree(param->hostname);
|
||||
param->hostname = (unsigned char *)mystrdup((char *)buf);
|
||||
if(param->hostname)free(param->hostname);
|
||||
param->hostname = (unsigned char *)strdup((char *)buf);
|
||||
if (ver == 5) {
|
||||
if ((res = sockgetcharcli(param, conf.timeouts[SINGLEBYTE_S], 0)) == EOF) {RETURN(441);}
|
||||
buf[0] = (unsigned char) res;
|
||||
@ -163,13 +163,13 @@ void * sockschild(struct clientparam* param) {
|
||||
else {
|
||||
if(sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]) < 0) {RETURN(441);}
|
||||
buf[127] = 0;
|
||||
if(param->srv->needuser && *buf && !param->username)param->username = (unsigned char *)mystrdup((char *)buf);
|
||||
if(param->srv->needuser && *buf && !param->username)param->username = (unsigned char *)strdup((char *)buf);
|
||||
if(!memcmp(SAADDR(¶m->req), "\0\0\0", 3)){
|
||||
param->service = S_SOCKS45;
|
||||
if(sockgetlinebuf(param, CLIENT, buf, BUFSIZE - 1, 0, conf.timeouts[STRING_S]) < 0) {RETURN(441);}
|
||||
buf[127] = 0;
|
||||
if(param->hostname)myfree(param->hostname);
|
||||
param->hostname = (unsigned char *)mystrdup((char *)buf);
|
||||
if(param->hostname)free(param->hostname);
|
||||
param->hostname = (unsigned char *)strdup((char *)buf);
|
||||
if(!getip46(param->srv->family, buf, (struct sockaddr *) ¶m->req)) RETURN(100);
|
||||
param->sinsr = param->req;
|
||||
}
|
||||
@ -341,7 +341,7 @@ fflush(stderr);
|
||||
case 1:
|
||||
if(param->redirectfunc){
|
||||
void *ret = (*param->redirectfunc)(param);
|
||||
if(buf)myfree(buf);
|
||||
if(buf)free(buf);
|
||||
return ret;
|
||||
}
|
||||
param->res = mapsocket(param, conf.timeouts[CONNECTION_L]);
|
||||
@ -420,7 +420,7 @@ fflush(stderr);
|
||||
printcommand(buf, command, param);
|
||||
|
||||
dolog(param, buf);
|
||||
myfree(buf);
|
||||
free(buf);
|
||||
}
|
||||
freeparam(param);
|
||||
return (NULL);
|
||||
|
||||
@ -36,8 +36,8 @@ int init_sql(char * s){
|
||||
if(!s) return 0;
|
||||
if(!sqlstring || strcmp(sqlstring, s)){
|
||||
string = sqlstring;
|
||||
sqlstring=mystrdup(s);
|
||||
if(string)myfree(string);
|
||||
sqlstring=strdup(s);
|
||||
if(string)free(string);
|
||||
}
|
||||
|
||||
if(hstmt || hdbc || henv) close_sql();
|
||||
@ -65,7 +65,7 @@ int init_sql(char * s){
|
||||
}
|
||||
SQLSetConnectAttr(hdbc, SQL_LOGIN_TIMEOUT, (void*)15, 0);
|
||||
}
|
||||
string = mystrdup(sqlstring);
|
||||
string = strdup(sqlstring);
|
||||
if(!string) return 0;
|
||||
datasource = strtok(string, ",");
|
||||
username = strtok(NULL, ",");
|
||||
@ -77,7 +77,7 @@ int init_sql(char * s){
|
||||
(SQLCHAR*) username, (SQLSMALLINT)((username)?strlen(username):0),
|
||||
(SQLCHAR*) password, (SQLSMALLINT)((password)?strlen(password):0));
|
||||
|
||||
myfree(string);
|
||||
free(string);
|
||||
if (retcode != SQL_SUCCESS && retcode != SQL_SUCCESS_WITH_INFO){
|
||||
SQLFreeHandle(SQL_HANDLE_DBC, hdbc);
|
||||
hdbc = NULL;
|
||||
|
||||
@ -21,7 +21,7 @@ void * tcppmchild(struct clientparam* param) {
|
||||
if(!strncmp((char *)param->srv->target, "unix:", 5)){
|
||||
make_un(param->srv->target + 5, (struct sockaddr_un *)¶m->sinsr);
|
||||
make_un(param->srv->target + 5, (struct sockaddr_un *)¶m->req);
|
||||
param->hostname = (unsigned char *)mystrdup((char *)param->srv->target);
|
||||
param->hostname = (unsigned char *)strdup((char *)param->srv->target);
|
||||
} else
|
||||
#endif
|
||||
if(
|
||||
|
||||
@ -111,7 +111,7 @@ int parsehello(int type, unsigned char *hello, unsigned len, char *sni, int * sn
|
||||
int tlstobufcli(struct clientparam *param){
|
||||
unsigned long len, newlen;
|
||||
if(!param->clibuf){
|
||||
if(!(param->clibuf = myalloc(SRVBUFSIZE))) return -1;
|
||||
if(!(param->clibuf = malloc(SRVBUFSIZE))) return -1;
|
||||
param->clibufsize = SRVBUFSIZE;
|
||||
param->clioffset = param->cliinbuf = 0;
|
||||
}
|
||||
@ -149,7 +149,7 @@ int tlstobufsrv(struct clientparam *param){
|
||||
param->cliinbuf = param->clioffset = 0;
|
||||
}
|
||||
if(!param->srvbuf){
|
||||
if(!(param->srvbuf = myalloc(SRVBUFSIZE))) return -1;
|
||||
if(!(param->srvbuf = malloc(SRVBUFSIZE))) return -1;
|
||||
param->srvbufsize = SRVBUFSIZE;
|
||||
param->srvoffset = param->srvinbuf = 0;
|
||||
}
|
||||
@ -186,11 +186,11 @@ void * tlsprchild(struct clientparam* param) {
|
||||
res = parsehello(1, param->clibuf, (unsigned)res, sni, &snipos, &lv, proto);
|
||||
if(res > 0){
|
||||
if(param->hostname){
|
||||
myfree(param->hostname);
|
||||
free(param->hostname);
|
||||
param->hostname = NULL;
|
||||
}
|
||||
else if (parsehostname(sni, param, param->srv->targetport? ntohs(param->srv->targetport):443)) RETURN (100);
|
||||
if (!param->hostname)param->hostname = (unsigned char *)mystrdup(sni);
|
||||
if (!param->hostname)param->hostname = (unsigned char *)strdup(sni);
|
||||
if(param->srv->singlepacket && snipos && res > 1){
|
||||
int len;
|
||||
|
||||
|
||||
@ -58,7 +58,7 @@ void * udppmchild(struct clientparam* param) {
|
||||
if(authres) { RETURN(authres); }
|
||||
if(!param->srv->singlepacket)hashadd(&udp_table, param, ¶m, MAX_COUNTER_TIME);
|
||||
if(!param->srvbuf){
|
||||
if(!(param->srvbuf = myalloc(UDPBUFSIZE)))RETURN(11);
|
||||
if(!(param->srvbuf = malloc(UDPBUFSIZE)))RETURN(11);
|
||||
param->srvbufsize = UDPBUFSIZE;
|
||||
}
|
||||
if(param->udp_nhops){
|
||||
|
||||
@ -58,7 +58,7 @@ int udpsockmap(struct clientparam *param, int timeo)
|
||||
int clisock_idx = -1, ctrlsock_idx = -1, ctrlsocksrv_idx = -1;
|
||||
int firstpacket = 1;
|
||||
if (param->srvbufsize < UDPBUFSIZE) {
|
||||
unsigned char *newbuf = myrealloc(param->srvbuf, UDPBUFSIZE);
|
||||
unsigned char *newbuf = realloc(param->srvbuf, UDPBUFSIZE);
|
||||
if (!newbuf) return 21;
|
||||
param->srvbuf = newbuf;
|
||||
param->srvbufsize = UDPBUFSIZE;
|
||||
|
||||
@ -382,7 +382,7 @@ void * adminchild(struct clientparam* param) {
|
||||
pp.inbuf = 0;
|
||||
pp.cp = param;
|
||||
|
||||
buf = myalloc(LINESIZE);
|
||||
buf = malloc(LINESIZE);
|
||||
if(!buf) {RETURN(555);}
|
||||
i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '\n', conf.timeouts[STRING_S]);
|
||||
if(i<5 || ((buf[0]!='G' || buf[1]!='E' || buf[2]!='T' || buf[3]!=' ' || buf[4]!='/') &&
|
||||
@ -396,7 +396,7 @@ void * adminchild(struct clientparam* param) {
|
||||
RETURN(702);
|
||||
}
|
||||
*sb = 0;
|
||||
req = mystrdup(buf + ((*buf == 'P')? 6 : 5));
|
||||
req = strdup(buf + ((*buf == 'P')? 6 : 5));
|
||||
while((i = sockgetlinebuf(param, CLIENT, (unsigned char *)buf, LINESIZE - 1, '\n', conf.timeouts[STRING_S])) > 2){
|
||||
buf[i] = 0;
|
||||
if(i > 19 && (!strncasecmp(buf, "authorization", 13))){
|
||||
@ -415,11 +415,11 @@ void * adminchild(struct clientparam* param) {
|
||||
sb = strchr((char *)username, ':');
|
||||
if(sb){
|
||||
*sb = 0;
|
||||
if(param->password)myfree(param->password);
|
||||
param->password = (unsigned char *)mystrdup(sb+1);
|
||||
if(param->password)free(param->password);
|
||||
param->password = (unsigned char *)strdup(sb+1);
|
||||
}
|
||||
if(param->username) myfree(param->username);
|
||||
param->username = (unsigned char *)mystrdup(username);
|
||||
if(param->username) free(param->username);
|
||||
param->username = (unsigned char *)strdup(username);
|
||||
continue;
|
||||
}
|
||||
else if(i > 15 && (!strncasecmp(buf, "content-length:", 15))){
|
||||
@ -611,9 +611,9 @@ CLEANRET:
|
||||
|
||||
|
||||
printstr(&pp, NULL);
|
||||
if(buf) myfree(buf);
|
||||
if(buf) free(buf);
|
||||
dolog(param, (unsigned char *)req);
|
||||
if(req)myfree(req);
|
||||
if(req)free(req);
|
||||
freeparam(param);
|
||||
return (NULL);
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user