From: jongfoster Date: Wed, 20 Feb 2002 23:17:23 +0000 (+0000) Subject: Detecting some out-of memory conditions and exiting with a log message. X-Git-Tag: v_2_9_11~9 X-Git-Url: http://www.privoxy.org/gitweb/?p=privoxy.git;a=commitdiff_plain;h=8d0001141e3f8c4f3c6f6287713416431f7c8a31 Detecting some out-of memory conditions and exiting with a log message. --- diff --git a/jcc.c b/jcc.c index cee16012..e9df2f3c 100644 --- a/jcc.c +++ b/jcc.c @@ -1,4 +1,4 @@ -const char jcc_rcs[] = "$Id: jcc.c,v 1.60 2001/12/30 14:07:32 steudten Exp $"; +const char jcc_rcs[] = "$Id: jcc.c,v 1.61 2002/01/17 21:01:52 jongfoster Exp $"; /********************************************************************* * * File : $Source: /cvsroot/ijbswa/current/jcc.c,v $ @@ -33,6 +33,9 @@ const char jcc_rcs[] = "$Id: jcc.c,v 1.60 2001/12/30 14:07:32 steudten Exp $"; * * Revisions : * $Log: jcc.c,v $ + * Revision 1.61 2002/01/17 21:01:52 jongfoster + * Moving all our URL and URL pattern parsing code to urlmatch.c. + * * Revision 1.60 2001/12/30 14:07:32 steudten * - Add signal handling (unix) * - Add SIGHUP handler (unix) @@ -760,10 +763,17 @@ static void chat(struct client_state *csp) * Downgrade http version from 1.1 to 1.0 if +downgrade * action applies */ - if (!strcmpic(http->ver, "HTTP/1.1") && csp->action->flags & ACTION_DOWNGRADE) + if ( (http->ssl == 0) + && (!strcmpic(http->ver, "HTTP/1.1")) + && (csp->action->flags & ACTION_DOWNGRADE)) { freez(http->ver); http->ver = strdup("HTTP/1.0"); + + if (http->ver == NULL) + { + log_error(LOG_LEVEL_FATAL, "Out of memory downgrading HTTP version"); + } } /* @@ -774,21 +784,25 @@ static void chat(struct client_state *csp) { freez(http->cmd); - http->cmd = strsav(http->cmd, http->gpc); - http->cmd = strsav(http->cmd, " "); + http->cmd = strdup(http->gpc); + string_append(&http->cmd, " "); if (fwd->forward_host) { - http->cmd = strsav(http->cmd, http->url); + string_append(&http->cmd, http->url); } else { - http->cmd = strsav(http->cmd, http->path); + string_append(&http->cmd, http->path); } - http->cmd = strsav(http->cmd, " "); - http->cmd = strsav(http->cmd, http->ver); + string_append(&http->cmd, " "); + string_append(&http->cmd, http->ver); + if (http->cmd == NULL) + { + log_error(LOG_LEVEL_FATAL, "Out of memory rewiting SSL command"); + } } enlist(csp->headers, http->cmd); @@ -941,6 +955,12 @@ static void chat(struct client_state *csp) log_error(LOG_LEVEL_CONNECT, "OK"); hdr = sed(client_patterns, add_client_headers, csp); + if (hdr == NULL) + { + /* FIXME Should handle error properly */ + log_error(LOG_LEVEL_FATAL, "Out of memory parsing client header"); + } + list_remove_all(csp->headers); if (fwd->forward_host || (http->ssl == 0)) @@ -1129,6 +1149,12 @@ static void chat(struct client_state *csp) } hdr = sed(server_patterns, add_server_headers, csp); + if (hdr == NULL) + { + /* FIXME Should handle error properly */ + log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header"); + } + n = strlen(hdr); if ((write_socket(csp->cfd, hdr, n) != n) @@ -1183,6 +1209,12 @@ static void chat(struct client_state *csp) log_error(LOG_LEVEL_ERROR, "Buffer size limit reached! Flushing and stepping back."); hdr = sed(server_patterns, add_server_headers, csp); + if (hdr == NULL) + { + /* FIXME Should handle error properly */ + log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header"); + } + n = strlen(hdr); byte_count += n; @@ -1271,6 +1303,12 @@ static void chat(struct client_state *csp) */ hdr = sed(server_patterns, add_server_headers, csp); + if (hdr == NULL) + { + /* FIXME Should handle error properly */ + log_error(LOG_LEVEL_FATAL, "Out of memory parsing server header"); + } + n = strlen(hdr); /* write the server's (modified) header to