Hi, Sometimes ago we received a patch for bug #2333 related to ajp12. It came from Roloff, Dirk [[EMAIL PROTECTED]] and I'd like to have your opinion before commiting it. Regards
De: Roloff, Dirk [[EMAIL PROTECTED]] Envoyé: mardi 26 juin 2001 19:10 À: '[EMAIL PROTECTED]' Objet: [PATCH] for BUG #2333 Hi Developers, tomcat 3.2.2 - mod_jk - using AJP12 with apache 1.3.20 I found this problem while a servlet use sendRedirect( very long URL ). The result was a not well formated HTTP-Header sending to the client. What is the maximum length of URL`s ??? I found something in the jk_ajp12_worker.c: reason saves the position in line but line is a buffer, that will be reused by jk_sb_gets() - so the reason-pointer that is passed to start_response() points somewhere - nobody knows where. My fix just define a static pointer to a buffer in which i copy the response value. This buffer will be rezized as needed - i hope this is a way you agree. I added a BUG-Report in the database and here the fix - was it the right way ? Thanks and have a nice day Dirk http://nagoya.apache.org/bugzilla/show_bug.cgi?id=2333 --- jk_ajp12_worker.c Thu Feb 1 23:50:09 2001 +++ jk_ajp12_worker.c.fixed Tue Jun 26 18:15:09 2001 @@ -482,6 +482,8 @@ jk_ws_service_t *s, jk_logger_t *l) { + static char *reason_buf = NULL; + static int reason_buf_len = 0; int status = 200; char *reason = NULL; char **names = NULL; @@ -541,7 +543,30 @@ jk_log(l, JK_LOG_ERROR, "ajpv12_handle_response, invalid status code\n"); return JK_FALSE; } + /* 26.06.2001 Dirk Roloff <[EMAIL PROTECTED]> + Save reason in a realloced buffer, because jk_sb_gets() will reuse ist line buffer. + Then the value will be lost - this will produce very strange output to the client. + I found this while a servlet try's to redirect to a very long URL. + The buffer will be rezised as needed but never call a free() on it - is it ok ? + */ + numeric = strtok(NULL, " \t"); + reason = NULL; + if( numeric ) { + int resonlen = strlen( numeric ) +1; + if(( NULL == reason_buf ) || (resonlen > reason_buf_len)) { + reason_buf = (char *)realloc( reason_buf, resonlen ); + reason_buf_len = resonlen; + } + if( reason_buf ) { + memcpy( reason_buf, numeric, resonlen ); + reason = reason_buf; + } + else + jk_log(l, JK_LOG_ERROR, "In jk_worker_t::ajpv12_handle_response, realloc(reason_buf,%d) failed\n", resonlen); + } + /* old stuff reason = strtok(NULL, " \t"); + removed by Dirk Roloff */ } else { if(headers_capacity == headers_len) { jk_log(l, JK_LOG_DEBUG, "ajpv12_handle_response, allocating header arrays\n");