From d413f089844873c5d88bb1580357124b45fab66c Mon Sep 17 00:00:00 2001 From: jongfoster Date: Sat, 9 Jun 2001 10:55:28 +0000 Subject: [PATCH] Changing BUFSIZ ==> BUFFER_SIZE --- actions.c | 11 +++++++---- errlog.c | 34 +++++++++++++++++++--------------- filters.c | 10 ++++++++-- gateway.c | 17 ++++++++++++++--- jcc.c | 12 +++++++++--- loadcfg.c | 15 ++++++++++----- loaders.c | 16 +++++++++++----- miscutil.c | 14 +++++++++++--- showargs.c | 10 +++++++--- 9 files changed, 96 insertions(+), 43 deletions(-) diff --git a/actions.c b/actions.c index 258862fd..f1d792e9 100644 --- a/actions.c +++ b/actions.c @@ -1,4 +1,4 @@ -const char actions_rcs[] = "$Id: actions.c,v 1.5 2001/06/03 19:11:48 oes Exp $"; +const char actions_rcs[] = "$Id: actions.c,v 1.6 2001/06/07 23:04:34 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/actions.c,v $ @@ -33,6 +33,9 @@ const char actions_rcs[] = "$Id: actions.c,v 1.5 2001/06/03 19:11:48 oes Exp $"; * * Revisions : * $Log: actions.c,v $ + * Revision 1.6 2001/06/07 23:04:34 jongfoster + * Made get_actions() static. + * * Revision 1.5 2001/06/03 19:11:48 oes * adapted to new enlist_unique arg format * @@ -906,7 +909,7 @@ int load_actions_file(struct client_state *csp) struct url_actions *last_perm; struct url_actions *perm; - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; struct file_list *fs; #define MODE_START_OF_FILE 1 #define MODE_ACTIONS 2 @@ -1003,7 +1006,7 @@ int load_actions_file(struct client_state *csp) { /* It's an actions block */ - char actions_buf[BUFSIZ]; + char actions_buf[BUFFER_SIZE]; char * end; /* set mode */ @@ -1055,7 +1058,7 @@ int load_actions_file(struct client_state *csp) else if (mode == MODE_ALIAS) { /* define an alias */ - char actions_buf[BUFSIZ]; + char actions_buf[BUFFER_SIZE]; struct action_alias * new_alias; int more = 1; diff --git a/errlog.c b/errlog.c index ae98ed3c..3832dbd7 100644 --- a/errlog.c +++ b/errlog.c @@ -1,4 +1,4 @@ -const char errlog_rcs[] = "$Id: errlog.c,v 1.10 2001/05/29 11:52:21 oes Exp $"; +const char errlog_rcs[] = "$Id: errlog.c,v 1.11 2001/06/01 18:14:49 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/errlog.c,v $ @@ -33,6 +33,10 @@ const char errlog_rcs[] = "$Id: errlog.c,v 1.10 2001/05/29 11:52:21 oes Exp $"; * * Revisions : * $Log: errlog.c,v $ + * Revision 1.11 2001/06/01 18:14:49 jongfoster + * Changing the calls to strerr() to check HAVE_STRERR (which is defined + * in config.h if appropriate) rather than the NO_STRERR macro. + * * Revision 1.10 2001/05/29 11:52:21 oes * Conditional compilation of w32_socket_error * @@ -262,7 +266,7 @@ void init_error_log(const char *prog_name, const char *logfname, int debuglevel) void log_error(int loglevel, char *fmt, ...) { va_list ap; - char outbuf[BUFSIZ]; + char outbuf[BUFFER_SIZE]; char * src = fmt; int outc = 0; long this_thread = 1; /* was: pthread_t this_thread;*/ @@ -339,9 +343,9 @@ void log_error(int loglevel, char *fmt, ...) va_start( ap, fmt ); /* build formatted message from fmt and var-args */ - while ((*src) && (outc < BUFSIZ-2)) + while ((*src) && (outc < BUFFER_SIZE-2)) { - char tempbuf[BUFSIZ]; + char tempbuf[BUFFER_SIZE]; char *sval; int ival; unsigned uval; @@ -366,7 +370,7 @@ void log_error(int loglevel, char *fmt, ...) ival = va_arg( ap, int ); oldoutc = outc; outc += sprintf(tempbuf, "%d", ival); - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { strcpy(outbuf + oldoutc, tempbuf); } @@ -379,7 +383,7 @@ void log_error(int loglevel, char *fmt, ...) uval = va_arg( ap, unsigned ); oldoutc = outc; outc += sprintf(tempbuf, "%u", uval); - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { strcpy(outbuf + oldoutc, tempbuf); } @@ -420,7 +424,7 @@ void log_error(int loglevel, char *fmt, ...) /* Never get here */ break; } - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { strcpy(outbuf + oldoutc, tempbuf); } @@ -440,7 +444,7 @@ void log_error(int loglevel, char *fmt, ...) sval = va_arg( ap, char * ); oldoutc = outc; outc += strlen(sval); - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { strcpy(outbuf + oldoutc, sval); } @@ -461,7 +465,7 @@ void log_error(int loglevel, char *fmt, ...) } oldoutc = outc; outc += ival; - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { memcpy(outbuf + oldoutc, sval, ival); } @@ -490,7 +494,7 @@ void log_error(int loglevel, char *fmt, ...) #endif /* ndef _WIN32 */ oldoutc = outc; outc += strlen(sval); - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { strcpy(outbuf + oldoutc, sval); } @@ -518,12 +522,12 @@ void log_error(int loglevel, char *fmt, ...) days = tm_now->tm_yday - gmt.tm_yday; hrs = ((days < -1 ? 24 : 1 < days ? -24 : days * 24) + tm_now->tm_hour - gmt.tm_hour); mins = hrs * 60 + tm_now->tm_min - gmt.tm_min; - strftime (tempbuf, BUFSIZ-6, "%d/%b/%Y:%H:%M:%S ", tm_now); + strftime (tempbuf, BUFFER_SIZE-6, "%d/%b/%Y:%H:%M:%S ", tm_now); sprintf (tempbuf + strlen(tempbuf), "%+03d%02d", mins / 60, abs(mins) % 60); } oldoutc = outc; outc += strlen(tempbuf); - if (outc < BUFSIZ-1) + if (outc < BUFFER_SIZE-1) { strcpy(outbuf + oldoutc, tempbuf); } @@ -554,20 +558,20 @@ void log_error(int loglevel, char *fmt, ...) /* done with var. args */ va_end( ap ); - if (outc >= BUFSIZ-2) + if (outc >= BUFFER_SIZE-2) { /* insufficient room for newline and trailing null. */ static const char warning[] = "... [too long, truncated]\n"; - if (outc < BUFSIZ) + if (outc < BUFFER_SIZE) { /* Need to add terminating null in this case. */ outbuf[outc] = '\0'; } /* Truncate output */ - outbuf[BUFSIZ - sizeof(warning)] = '\0'; + outbuf[BUFFER_SIZE - sizeof(warning)] = '\0'; /* Append warning */ strcat(outbuf, warning); diff --git a/filters.c b/filters.c index b31cb434..d6965cb9 100644 --- a/filters.c +++ b/filters.c @@ -1,4 +1,4 @@ -const char filters_rcs[] = "$Id: filters.c,v 1.15 2001/06/03 19:12:00 oes Exp $"; +const char filters_rcs[] = "$Id: filters.c,v 1.16 2001/06/07 23:10:26 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/filters.c,v $ @@ -38,6 +38,12 @@ const char filters_rcs[] = "$Id: filters.c,v 1.15 2001/06/03 19:12:00 oes Exp $" * * Revisions : * $Log: filters.c,v $ + * Revision 1.16 2001/06/07 23:10:26 jongfoster + * Allowing unanchored domain patterns to back off and retry + * if they partially match. Optimized right-anchored patterns. + * Moving ACL and forward files into config file. + * Replacing struct gateway with struct forward_spec + * * Revision 1.15 2001/06/03 19:12:00 oes * extracted-CGI relevant stuff * @@ -944,7 +950,7 @@ const struct forward_spec * forward_url(struct http_request *http, struct url_spec dsplit(char *domain) { struct url_spec ret[1]; - char *v[BUFSIZ]; + char *v[BUFFER_SIZE]; int size; char *p; diff --git a/gateway.c b/gateway.c index 8716e16e..13273f6c 100644 --- a/gateway.c +++ b/gateway.c @@ -1,4 +1,4 @@ -const char gateway_rcs[] = "$Id: gateway.c,v 1.1.1.1 2001/05/15 13:58:54 oes Exp $"; +const char gateway_rcs[] = "$Id: gateway.c,v 1.2 2001/06/07 23:11:38 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/gateway.c,v $ @@ -34,6 +34,17 @@ const char gateway_rcs[] = "$Id: gateway.c,v 1.1.1.1 2001/05/15 13:58:54 oes Exp * * Revisions : * $Log: gateway.c,v $ + * Revision 1.2 2001/06/07 23:11:38 jongfoster + * Removing gateways[] list - no longer used. + * Replacing function pointer in struct gateway with a directly + * called function forwarded_connect(), which can do the common + * task of deciding whether to connect to the web server or HTTP + * proxy. + * Replacing struct gateway with struct forward_spec + * Fixing bug with SOCKS4A and HTTP proxy server in combination. + * It was a bug which led to the connection being made to the web + * server rather than the HTTP proxy, and also a buffer overrun. + * * Revision 1.1.1.1 2001/05/15 13:58:54 oes * Initial import of version 2.9.3 source tree * @@ -169,8 +180,8 @@ static int socks4_connect(const struct forward_spec * fwd, struct client_state *csp) { int web_server_addr; - unsigned char cbuf[BUFSIZ]; - unsigned char sbuf[BUFSIZ]; + unsigned char cbuf[BUFFER_SIZE]; + unsigned char sbuf[BUFFER_SIZE]; struct socks_op *c = (struct socks_op *)cbuf; struct socks_reply *s = (struct socks_reply *)sbuf; int n; diff --git a/jcc.c b/jcc.c index 102f1b00..f1f7e7eb 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.18 2001/06/03 19:12:16 oes Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.19 2001/06/07 23:12:52 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,11 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.18 2001/06/03 19:12:16 oes Exp $"; * * Revisions : * $Log: jcc.c,v $ + * Revision 1.19 2001/06/07 23:12:52 jongfoster + * Replacing function pointer in struct gateway with a directly + * called function forwarded_connect(). + * Replacing struct gateway with struct forward_spec + * * Revision 1.18 2001/06/03 19:12:16 oes * introduced new cgi handling * @@ -379,7 +384,8 @@ static void chat(struct client_state *csp) #define IS_ENABLED_AND IS_TOGGLED_ON_AND IS_NOT_FORCED_AND - char buf[BUFSIZ], *hdr, *p, *req; + char buf[BUFFER_SIZE]; + char *hdr, *p, *req; char *err = NULL; char *eno; fd_set rfds; @@ -1428,7 +1434,7 @@ static void listen_loop(void) if (child_id < 0) /* failed */ { - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; log_error(LOG_LEVEL_ERROR, "can't fork: %E"); diff --git a/loadcfg.c b/loadcfg.c index 96e760a9..4ce1d20d 100644 --- a/loadcfg.c +++ b/loadcfg.c @@ -1,5 +1,5 @@ /* vim:ts=3: */ -const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.14 2001/06/07 14:46:25 joergs Exp $"; +const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.15 2001/06/07 23:13:40 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loadcfg.c,v $ @@ -36,6 +36,11 @@ const char loadcfg_rcs[] = "$Id: loadcfg.c,v 1.14 2001/06/07 14:46:25 joergs Exp * * Revisions : * $Log: loadcfg.c,v $ + * Revision 1.15 2001/06/07 23:13:40 jongfoster + * Merging ACL and forward files into config file. + * Cosmetic: Sorting config file options alphabetically. + * Cosmetic: Adding brief syntax comments to config file options. + * * Revision 1.14 2001/06/07 14:46:25 joergs * Missing make_path() added for re_filterfile. * @@ -433,7 +438,7 @@ void unload_configfile (void * data) *********************************************************************/ struct configuration_spec * load_config(void) { - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; char *p, *q; FILE *configfp = NULL; struct configuration_spec * config = NULL; @@ -496,9 +501,9 @@ struct configuration_spec * load_config(void) while (read_config_line(buf, sizeof(buf), configfp, fs) != NULL) { - char cmd[BUFSIZ]; - char arg[BUFSIZ]; - char tmp[BUFSIZ]; + char cmd[BUFFER_SIZE]; + char arg[BUFFER_SIZE]; + char tmp[BUFFER_SIZE]; #ifdef ACL_FILES struct access_control_list *cur_acl; #endif /* def ACL_FILES */ diff --git a/loaders.c b/loaders.c index 9f343312..e6edc55d 100644 --- a/loaders.c +++ b/loaders.c @@ -1,4 +1,4 @@ -const char loaders_rcs[] = "$Id: loaders.c,v 1.14 2001/06/01 03:27:04 oes Exp $"; +const char loaders_rcs[] = "$Id: loaders.c,v 1.15 2001/06/07 23:14:14 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/loaders.c,v $ @@ -35,6 +35,12 @@ const char loaders_rcs[] = "$Id: loaders.c,v 1.14 2001/06/01 03:27:04 oes Exp $" * * Revisions : * $Log: loaders.c,v $ + * Revision 1.15 2001/06/07 23:14:14 jongfoster + * Removing ACL and forward file loaders - these + * files have been merged into the config file. + * Cosmetic: Moving unloader funcs next to their + * respective loader funcs + * * Revision 1.14 2001/06/01 03:27:04 oes * Fixed line continuation problem * @@ -359,7 +365,7 @@ int create_url_spec(struct url_spec * url, char * buf) if (url->path) { int errcode; - char rebuf[BUFSIZ]; + char rebuf[BUFFER_SIZE]; if (NULL == (url->preg = zalloc(sizeof(*url->preg)))) { @@ -569,7 +575,7 @@ int check_file_changed(const struct file_list * current, char *read_config_line(char *buf, int buflen, FILE *fp, struct file_list *fs) { char *p, *q; - char linebuf[BUFSIZ]; + char linebuf[BUFFER_SIZE]; int contflag = 0; *buf = '\0'; @@ -692,7 +698,7 @@ int load_trustfile(struct client_state *csp) struct block_spec *b, *bl; struct url_spec **tl; - char buf[BUFSIZ], *p, *q; + char buf[BUFFER_SIZE], *p, *q; int reject, trusted; struct file_list *fs; @@ -867,7 +873,7 @@ int load_re_filterfile(struct client_state *csp) struct re_filterfile_spec *bl; struct file_list *fs; - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; int error; pcrs_job *dummy; diff --git a/miscutil.c b/miscutil.c index 8dcdd953..404602e3 100644 --- a/miscutil.c +++ b/miscutil.c @@ -1,5 +1,5 @@ /* vim:ts=3: */ -const char miscutil_rcs[] = "$Id: miscutil.c,v 1.10 2001/06/07 14:51:38 joergs Exp $"; +const char miscutil_rcs[] = "$Id: miscutil.c,v 1.11 2001/06/07 23:09:19 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/miscutil.c,v $ @@ -37,6 +37,9 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.10 2001/06/07 14:51:38 joergs E * * Revisions : * $Log: miscutil.c,v $ + * Revision 1.11 2001/06/07 23:09:19 jongfoster + * Cosmetic indentation changes. + * * Revision 1.10 2001/06/07 14:51:38 joergs * make_path() no longer adds '/' if the dir already ends in '/'. * @@ -159,7 +162,12 @@ const char miscutil_rcs[] = "$Id: miscutil.c,v 1.10 2001/06/07 14:51:38 joergs E #include #include -#include "miscutil.h" +/* + * FIXME: Only need project.h for BUFFER_SIZE. It would be nice + * to remove this dependency. + */ +#include "project.h" +#include "miscutil.h" #include "errlog.h" const char miscutil_h_rcs[] = MISCUTIL_H_VERSION; @@ -279,7 +287,7 @@ char *strdup( const char *s ) char *safe_strerror(int err) { char *s = NULL; - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; #ifdef HAVE_STRERROR diff --git a/showargs.c b/showargs.c index 6bd48609..e4971824 100644 --- a/showargs.c +++ b/showargs.c @@ -1,4 +1,4 @@ -const char showargs_rcs[] = "$Id: showargs.c,v 1.13 2001/06/06 09:37:59 sarantis Exp $"; +const char showargs_rcs[] = "$Id: showargs.c,v 1.14 2001/06/07 23:15:40 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/showargs.c,v $ @@ -33,6 +33,10 @@ const char showargs_rcs[] = "$Id: showargs.c,v 1.13 2001/06/06 09:37:59 sarantis * * Revisions : * $Log: showargs.c,v $ + * Revision 1.14 2001/06/07 23:15:40 jongfoster + * Removing config->proxy_args_gateways + * Missing return statement added to end_proxy_args(). + * * Revision 1.13 2001/06/06 09:37:59 sarantis * Fix misplaced comment start. * @@ -240,7 +244,7 @@ const char showargs_h_rcs[] = SHOWARGS_H_VERSION; *********************************************************************/ void savearg(char *c, char *o, struct configuration_spec * config) { - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; *buf = '\0'; @@ -323,7 +327,7 @@ void init_proxy_args(int argc, const char *argv[], struct configuration_spec * c char *end_proxy_args(struct configuration_spec * config) { char *b = NULL; - char buf[BUFSIZ]; + char buf[BUFFER_SIZE]; /* Instead of including *all* dot h's in the project (thus creating a * tremendous amount of dependencies), I will concede to declaring them -- 2.39.2