From dc41b3533326d745c65afaea4cb34c229a31d0c3 Mon Sep 17 00:00:00 2001 From: Vasily Date: Fri, 23 Nov 2018 17:59:03 +0300 Subject: [PATCH 1/2] Basic Auth: allow almost all possible characters for user/pass previously was restricted to alphanumeric chars only. --- src/conf.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/conf.c b/src/conf.c index 5a87c68..5ebf179 100644 --- a/src/conf.c +++ b/src/conf.c @@ -52,6 +52,8 @@ #define BOOL "(yes|on|no|off)" #define INT "((0x)?[[:digit:]]+)" #define ALNUM "([-a-z0-9._]+)" +#define USERNAME "([^:]*)" +#define PASSWORD "([^@]*)" #define IP "((([0-9]{1,3})\\.){3}[0-9]{1,3})" #define IPMASK "(" IP "(/[[:digit:]]+)?)" #define IPV6 "(" \ @@ -257,7 +259,7 @@ struct { }, { BEGIN "(upstream)" WS "(http|socks4|socks5)" WS - "(" ALNUM /*username*/ ":" ALNUM /*password*/ "@" ")?" + "(" USERNAME /*username*/ ":" PASSWORD /*password*/ "@" ")?" "(" IP "|" ALNUM ")" ":" INT "(" WS STR ")?" END, handle_upstream, NULL From b131f45cbb4b829d7e520392a2dcfc9b41044351 Mon Sep 17 00:00:00 2001 From: rofl0r Date: Sat, 15 Dec 2018 17:09:04 +0000 Subject: [PATCH 2/2] child.c: properly initialize fdset for each select() call (#216) it was reported that because the fdset was only initialized once, tinyproxy would fail to properly listen on more than one interface. closes #214 closes #127 --- src/child.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/src/child.c b/src/child.c index effb2ae..60f8ead 100644 --- a/src/child.c +++ b/src/child.c @@ -206,27 +206,27 @@ static void child_main (struct child_s *ptr) * We have to wait for connections on multiple fds, * so use select. */ - - FD_ZERO(&rfds); - - for (i = 0; i < vector_length(listen_fds); i++) { - int *fd = (int *) vector_getentry(listen_fds, i, NULL); - - ret = socket_nonblocking(*fd); - if (ret != 0) { - log_message(LOG_ERR, "Failed to set the listening " - "socket %d to non-blocking: %s", - fd, strerror(errno)); - exit(1); - } - - FD_SET(*fd, &rfds); - maxfd = max(maxfd, *fd); - } - while (!config.quit) { + int listenfd = -1; + FD_ZERO(&rfds); + + for (i = 0; i < vector_length(listen_fds); i++) { + int *fd = (int *) vector_getentry(listen_fds, i, NULL); + + ret = socket_nonblocking(*fd); + if (ret != 0) { + log_message(LOG_ERR, "Failed to set the listening " + "socket %d to non-blocking: %s", + fd, strerror(errno)); + exit(1); + } + + FD_SET(*fd, &rfds); + maxfd = max(maxfd, *fd); + } + ptr->status = T_WAITING; clilen = sizeof(struct sockaddr_storage);