Compare commits

...

4 Commits

Author SHA1 Message Date
Capi Etheriel
5e472363f1
Merge 090baeab33 into 12c9039ea4 2026-02-12 17:18:34 +03:00
Vladimir Dubrovin
12c9039ea4 Fixed: crash on invalid configuration file
Some checks failed
C/C++ CI / ${{ matrix.target }} (macos-15) (push) Has been cancelled
C/C++ CI / ${{ matrix.target }} (ubuntu-24.04-arm) (push) Has been cancelled
C/C++ CI / ${{ matrix.target }} (ubuntu-latest) (push) Has been cancelled
C/C++ CI / ${{ matrix.target }} (windows-2022) (push) Has been cancelled
2026-01-28 19:40:58 +03:00
Vladimir Dubrovin
1a970c5c98 Fixed: memory corruptions on config parsing 2026-01-28 19:13:41 +03:00
Capi Etheriel
090baeab33
document default log format 2023-09-08 10:31:26 -03:00
3 changed files with 26 additions and 13 deletions

View File

@ -291,7 +291,7 @@ Also, you must specify logformat to build SQL query, to insert recod into
log, see <A HREF="#LOGFORMAT">How to setup logging format</A> log, see <A HREF="#LOGFORMAT">How to setup logging format</A>
</p> </p>
<p> <p>
Rotation and archiving may be set up with log, rotate ¨ archiver commands Rotation and archiving may be set up with log, rotate ¨ archiver commands
<pre> <pre>
log filename LOGTYPE log filename LOGTYPE
</pre> </pre>
@ -367,12 +367,19 @@ logformat "L%t.%. %N.%p %E %U %C:%c %R:%r %O %I %h %T"
<br>(no line breaks) <br>(no line breaks)
</p> </p>
<p> <p>
If ODBC used, logformat should specify SQL command, If ODBC is used, logformat should specify SQL command,
to insert record into log, for example to insert record into log, for example
<p><pre> <p><pre>
logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre> logformat "-\'+_GINSERT INTO proxystat VALUES (%t, '%c', '%U', %I)"</pre>
<br>(no line breaks) <br>(no line breaks)
<br>-\'+_ instructs to replace characters \ and ' with _ <br>-\'+_ instructs to replace characters \ and ' with _
</p>
<p>
If no log format is set, it will fall back to the default log format:
<pre>
logformat "G%y%m%d%H%M%S.%. %p %E %U %C:%c %R:%r %O %I %h %T"
</pre>
</p> </p>
<li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A> <li><A NAME="LOGANALIZERS">How to use log analizers with 3proxy</A>
<p> <p>
@ -475,7 +482,7 @@ proxy -p8080 -i192.168.2.1
</p> </p>
<li><a name="ISFTP"><i>How to setup FTP proxy</i></a></li> <li><a name="ISFTP"><i>How to setup FTP proxy</i></a></li>
<p> <p>
There is FTP over HTTP (what is called FTP proxy in browsers) and FTP over FTP ¯à®ªá¨ There is FTP over HTTP (what is called FTP proxy in browsers) and FTP over FTP ¯à®ªá¨
(what is called FTP proxy in file managers and FTP clients). For browsers, there is no need to start additional (what is called FTP proxy in file managers and FTP clients). For browsers, there is no need to start additional
proxy service, 'proxy' supports FTP over HTTP, configure 'proxy' port as an FTP proxy. For ftp clients and file proxy service, 'proxy' supports FTP over HTTP, configure 'proxy' port as an FTP proxy. For ftp clients and file
managers use ftppr. FTP proxy supports both active and passive mode with client, but always use passive mode with FTP servers. managers use ftppr. FTP proxy supports both active and passive mode with client, but always use passive mode with FTP servers.
@ -736,7 +743,7 @@ no need to run these services expicitly. Local redirections are usefull if
you want to see and control via ACLs protocol specific parameters, e.g. you want to see and control via ACLs protocol specific parameters, e.g.
filenames requests thorugh FTP while clients are using SOCKS. filenames requests thorugh FTP while clients are using SOCKS.
</p> </p>
<li><a name="SOCKSREDIR">Š ª ã¯à ¢«ïâì «®ª «ì­ë¬¨ ¯¥à¥­ ¯à ¢«¥­¨ï¬¨</a> <li><a name="SOCKSREDIR">Š ª ã¯à ¢«ïâì «®ª «ì­ë¬¨ ¯¥à¥­ ¯à ¢«¥­¨ï¬¨</a>
<p> <p>
<p><i>Q: What is it for?</i></p> <p><i>Q: What is it for?</i></p>
A: To have control based on request and to have URLs and another protocol specific parameters to be logged. A: To have control based on request and to have URLs and another protocol specific parameters to be logged.

View File

@ -105,6 +105,10 @@ unsigned char * dologname (unsigned char *buf, unsigned char *name, const unsign
struct tm *ts; struct tm *ts;
ts = localtime(&t); ts = localtime(&t);
if(strlen((char *)name) >= 4096){
*buf = 0;
return buf;
}
if(strchr((char *)name, '%')){ if(strchr((char *)name, '%')){
struct clientparam fakecli; struct clientparam fakecli;
@ -905,7 +909,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
if(argc > 0 && strcmp("*", (char *)argv[0])) { if(argc > 0 && strcmp("*", (char *)argv[0])) {
arg = argv[0]; arg = argv[0];
arg = (unsigned char *)strtok((char *)arg, ","); arg = (unsigned char *)strtok((char *)arg, ",");
do { if(arg) do {
if(!acl->users) { if(!acl->users) {
acl->users = userl = myalloc(sizeof(struct userlist)); acl->users = userl = myalloc(sizeof(struct userlist));
} }
@ -924,7 +928,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
} }
if(argc > 1 && strcmp("*", (char *)argv[1])) { if(argc > 1 && strcmp("*", (char *)argv[1])) {
arg = (unsigned char *)strtok((char *)argv[1], ","); arg = (unsigned char *)strtok((char *)argv[1], ",");
do { if(arg) do {
if(!acl->src) { if(!acl->src) {
acl->src = ipl = myalloc(sizeof(struct iplist)); acl->src = ipl = myalloc(sizeof(struct iplist));
} }
@ -945,7 +949,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
} }
if(argc > 2 && strcmp("*", (char *)argv[2])) { if(argc > 2 && strcmp("*", (char *)argv[2])) {
arg = (unsigned char *)strtok((char *)argv[2], ","); arg = (unsigned char *)strtok((char *)argv[2], ",");
do { if(arg) do {
int arglen; int arglen;
unsigned char *pattern; unsigned char *pattern;
struct iplist tmpip={NULL}; struct iplist tmpip={NULL};
@ -1002,7 +1006,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
} }
if(argc > 3 && strcmp("*", (char *)argv[3])) { if(argc > 3 && strcmp("*", (char *)argv[3])) {
arg = (unsigned char *)strtok((char *)argv[3], ","); arg = (unsigned char *)strtok((char *)argv[3], ",");
do { if(arg) do {
if(!acl->ports) { if(!acl->ports) {
acl->ports = portl = myalloc(sizeof(struct portlist)); acl->ports = portl = myalloc(sizeof(struct portlist));
} }
@ -1025,7 +1029,7 @@ struct ace * make_ace (int argc, unsigned char ** argv){
} }
if(argc > 4 && strcmp("*", (char *)argv[4])) { if(argc > 4 && strcmp("*", (char *)argv[4])) {
arg = (unsigned char *)strtok((char *)argv[4], ","); arg = (unsigned char *)strtok((char *)argv[4], ",");
do { if(arg) do {
if(!strcmp((char *)arg, "CONNECT")){ if(!strcmp((char *)arg, "CONNECT")){
acl->operation |= CONNECT; acl->operation |= CONNECT;
} }
@ -1682,7 +1686,7 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
} }
switch(*str){ switch(*str){
case '\0': case '\0':
if(comment) return -1; if(comment || incbegin) return -1;
argm[argc] = 0; argm[argc] = 0;
return argc; return argc;
case '$': case '$':
@ -1709,14 +1713,14 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
argc--; argc--;
if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){ if((fd = open((char *)incbegin+1, O_RDONLY)) <= 0){
fprintf(stderr, "Failed to open %s\n", incbegin+1); fprintf(stderr, "Failed to open %s\n", incbegin+1);
break; return -1;
} }
if((*bufsize - *inbuf) <STRINGBUF){ if((*bufsize - *inbuf) <STRINGBUF){
*bufsize += STRINGBUF; *bufsize += STRINGBUF;
if(!(buf = myrealloc(buf, *bufsize))){ if(!(buf = myrealloc(buf, *bufsize))){
fprintf(stderr, "Failed to allocate memory for %s\n", incbegin+1); fprintf(stderr, "Failed to allocate memory for %s\n", incbegin+1);
close(fd); close(fd);
break; return -1;
} }
} }
len = 0; len = 0;
@ -1727,7 +1731,7 @@ int parsestr (unsigned char *str, unsigned char **argm, int nitems, unsigned cha
if((res = read(fd, buf+*inbuf+len, STRINGBUF-(1+len))) <= 0) { if((res = read(fd, buf+*inbuf+len, STRINGBUF-(1+len))) <= 0) {
perror((char *)incbegin+1); perror((char *)incbegin+1);
close(fd); close(fd);
break; return -1;
} }
close(fd); close(fd);
buf[*inbuf+res+len] = 0; buf[*inbuf+res+len] = 0;

View File

@ -300,6 +300,8 @@ int dobuf2(struct clientparam * param, unsigned char * buf, const unsigned char
break; break;
} }
case 0:
j--;
default: default:
buf[i++] = format[j]; buf[i++] = format[j];
} }