Fix error handling in server_content_type()
[privoxy.git] / parsers.c
index 3f5c626..4111996 100644 (file)
--- a/parsers.c
+++ b/parsers.c
@@ -1,4 +1,4 @@
-const char parsers_rcs[] = "$Id: parsers.c,v 1.291 2014/07/25 11:56:54 fabiankeil Exp $";
+const char parsers_rcs[] = "$Id: parsers.c,v 1.294 2014/10/18 11:30:04 fabiankeil Exp $";
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
 /*********************************************************************
  *
  * File        :  $Source: /cvsroot/ijbswa/current/parsers.c,v $
@@ -2195,11 +2195,12 @@ static jb_err server_content_type(struct client_state *csp, char **header)
        */
       if ((csp->content_type & CT_TEXT) || (csp->action->flags & ACTION_FORCE_TEXT_MODE))
       {
        */
       if ((csp->content_type & CT_TEXT) || (csp->action->flags & ACTION_FORCE_TEXT_MODE))
       {
+         jb_err err;
          freez(*header);
          *header = strdup_or_die("Content-Type: ");
          freez(*header);
          *header = strdup_or_die("Content-Type: ");
-         string_append(header, csp->action->string[ACTION_STRING_CONTENT_TYPE]);
 
 
-         if (header == NULL)
+         err = string_append(header, csp->action->string[ACTION_STRING_CONTENT_TYPE]);
+         if (JB_ERR_OK != err)
          {
             log_error(LOG_LEVEL_HEADER, "Insufficient memory to replace Content-Type!");
             return JB_ERR_MEMORY;
          {
             log_error(LOG_LEVEL_HEADER, "Insufficient memory to replace Content-Type!");
             return JB_ERR_MEMORY;
@@ -2321,8 +2322,7 @@ static jb_err server_content_encoding(struct client_state *csp, char **header)
       /*
        * Log a warning if the user expects the content to be filtered.
        */
       /*
        * Log a warning if the user expects the content to be filtered.
        */
-      if ((csp->rlist != NULL) &&
-         (!list_is_empty(csp->action->multi[ACTION_MULTI_FILTER])))
+      if (content_filters_enabled(csp->action))
       {
          log_error(LOG_LEVEL_INFO,
             "SDCH-compressed content detected, content filtering disabled. "
       {
          log_error(LOG_LEVEL_INFO,
             "SDCH-compressed content detected, content filtering disabled. "
@@ -3865,15 +3865,21 @@ static jb_err server_http(struct client_state *csp, char **header)
    {
       p++;
       reason_phrase = strchr(p, ' ');
    {
       p++;
       reason_phrase = strchr(p, ' ');
-      if (reason_phrase != NULL)
-      {
-         reason_phrase++;
-      }
    }
 
    }
 
-   if ((reason_phrase == NULL) || (reason_phrase[0] == '\0') ||
-      (3 != sscanf(*header, "HTTP/%u.%u %u", &major_version,
-         &minor_version, &(csp->http->status))))
+   if (reason_phrase != NULL)
+   {
+      reason_phrase++;
+   }
+   else
+   {
+      log_error(LOG_LEVEL_ERROR,
+         "Response line lacks reason phrase: %s", *header);
+      reason_phrase="";
+   }
+
+   if (3 != sscanf(*header, "HTTP/%u.%u %u", &major_version,
+         &minor_version, &(csp->http->status)))
    {
       log_error(LOG_LEVEL_ERROR,
          "Failed to parse the response line: %s", *header);
    {
       log_error(LOG_LEVEL_ERROR,
          "Failed to parse the response line: %s", *header);