X-Git-Url: https://granicus.if.org/sourcecode?a=blobdiff_plain;f=server%2Futil_script.c;h=703d16009472b34d73e0b36e64c9c9d63380dfa9;hb=36ab7eb1eb554444ac1d6c06d1988ed33857b6f7;hp=3f7d847a7de169387b89a465be8f24d13bcac01a;hpb=732f60dc2c97a388a2f22efbe128aece959debad;p=apache diff --git a/server/util_script.c b/server/util_script.c index 3f7d847a7d..703d160094 100644 --- a/server/util_script.c +++ b/server/util_script.c @@ -553,7 +553,7 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer, if (!(l = strchr(w, ':'))) { if (!buffer) { /* Soak up all the script output - may save an outright kill */ - while ((*getsfunc) (w, MAX_STRING_LEN - 1, getsfunc_data)) { + while ((*getsfunc)(w, MAX_STRING_LEN - 1, getsfunc_data) > 0) { continue; } } @@ -592,11 +592,11 @@ AP_DECLARE(int) ap_scan_script_header_err_core_ex(request_rec *r, char *buffer, if (!ap_is_HTTP_VALID_RESPONSE(cgi_status)) ap_log_rerror(SCRIPT_LOG_MARK, APLOG_ERR|APLOG_TOCLIENT, 0, r, "Invalid status line from script '%s': %s", - apr_filepath_name_get(r->filename), w); + apr_filepath_name_get(r->filename), l); else ap_log_rerror(SCRIPT_LOG_MARK, APLOG_TRACE1, 0, r, "Status line from script '%s': %s", - apr_filepath_name_get(r->filename), w); + apr_filepath_name_get(r->filename), l); r->status_line = apr_pstrdup(r->pool, l); } else if (!strcasecmp(w, "Location")) { @@ -672,7 +672,8 @@ static int getsfunc_BRIGADE(char *buf, int len, void *arg) apr_status_t rv; int done = 0; - while ((dst < dst_end) && !done && !APR_BUCKET_IS_EOS(e)) { + while ((dst < dst_end) && !done && e != APR_BRIGADE_SENTINEL(bb) + && !APR_BUCKET_IS_EOS(e)) { const char *bucket_data; apr_size_t bucket_data_len; const char *src; @@ -682,6 +683,7 @@ static int getsfunc_BRIGADE(char *buf, int len, void *arg) rv = apr_bucket_read(e, &bucket_data, &bucket_data_len, APR_BLOCK_READ); if (rv != APR_SUCCESS || (bucket_data_len == 0)) { + *dst = '\0'; return APR_STATUS_IS_TIMEUP(rv) ? -1 : 0; } src = bucket_data; @@ -705,7 +707,7 @@ static int getsfunc_BRIGADE(char *buf, int len, void *arg) e = next; } *dst = 0; - return 1; + return done; } AP_DECLARE(int) ap_scan_script_header_err_brigade(request_rec *r, @@ -738,8 +740,10 @@ static int getsfunc_STRING(char *w, int len, void *pvastrs) const char *p; int t; - if (!strs->curpos || !*strs->curpos) + if (!strs->curpos || !*strs->curpos) { + w[0] = '\0'; return 0; + } p = ap_strchr_c(strs->curpos, '\n'); if (p) ++p;