Commit 3df1676b authored by Greg Ames's avatar Greg Ames
Browse files

insure that canned error msgs are translated to ascii before leaving

an ebcdic server in worst case scenarios.


git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@88361 13f79535-47bb-0310-9956-ffa450edef68
parent a0cf2a57
Loading
Loading
Loading
Loading
+10 −0
Original line number Diff line number Diff line
@@ -96,6 +96,14 @@ void ap_xlate_proto_to_ascii(char *buffer, apr_size_t len);
 */
void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len);

/**
 * Convert protocol data from the implementation charater
 * set to ASCII, then send it.
 * @param r   the current request
 * @param ... the strings to write, followed by a NULL pointer
 */
int ap_rvputs_proto_in_ascii(request_rec *r, ...);

#ifdef __cplusplus
}
#endif
@@ -105,6 +113,8 @@ void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len);
#define ap_xlate_proto_to_ascii(x,y)          /* NOOP */
#define ap_xlate_proto_from_ascii(x,y)        /* NOOP */

#define ap_rvputs_proto_in_ascii  ap_rvputs

#endif  /* APR_CHARSET_EBCDIC */
    
#endif  /* !APACHE_UTIL_EBCDIC_H */
+11 −5
Original line number Diff line number Diff line
@@ -2043,22 +2043,28 @@ AP_DECLARE(void) ap_send_error_response(request_rec *r, int recursive_error)
        /* folks decided they didn't want the error code in the H1 text */
        h1 = &title[4];

        ap_rvputs(rlast,
        /* can't count on a charset filter being in place here, 
         * so do ebcdic->ascii translation explicity (if needed)
         */

        ap_rvputs_proto_in_ascii(rlast,
                  DOCTYPE_HTML_2_0
                  "<HTML><HEAD>\n<TITLE>", title,
                  "</TITLE>\n</HEAD><BODY>\n<H1>", h1, "</H1>\n",
                  NULL);
        
        ap_rputs(get_canned_error_string(status, r, location),rlast); 
        ap_rvputs_proto_in_ascii(rlast,
                                 get_canned_error_string(status, r, location),
                                 NULL); 

        if (recursive_error) {
            ap_rvputs(rlast, "<P>Additionally, a ",
            ap_rvputs_proto_in_ascii(rlast, "<P>Additionally, a ",
                      status_lines[ap_index_of_response(recursive_error)],
                      "\nerror was encountered while trying to use an "
                      "ErrorDocument to handle the request.\n", NULL);
        }
        ap_rputs(ap_psignature("<HR>\n", r), rlast);
        ap_rputs("</BODY></HTML>\n", rlast);
        ap_rvputs_proto_in_ascii(rlast, ap_psignature("<HR>\n", r), NULL);
        ap_rvputs_proto_in_ascii(rlast, "</BODY></HTML>\n", NULL);
    }
    ap_finalize_request_protocol(r);
}
+24 −0
Original line number Diff line number Diff line
@@ -141,4 +141,28 @@ void ap_xlate_proto_from_ascii(char *buffer, apr_size_t len)
                          buffer, &outbytes_left);
}

int ap_rvputs_proto_in_ascii(request_rec *r, ...)
{
    va_list va;
    const char *s;
    char *ascii_s;
    apr_size_t len;
    apr_size_t written = 0;

    va_start(va, r);
    while (1) {
        s = va_arg(va, const char *);
        if (s == NULL)
            break;
        len = strlen(s);
        ascii_s = apr_pstrndup(r->pool, s, len);
        ap_xlate_proto_to_ascii(ascii_s, len);
        if (ap_rputs(ascii_s, r) < 0)
            return -1;
        written += len;
    }
    va_end(va);
 
    return written;
}    
#endif /* APR_CHARSET_EBCDIC */