Make sure the getsfunc_*() functions used by ap_scan_script_header_err*()
authorStefan Fritsch <sf@apache.org>
Tue, 14 Feb 2012 21:18:22 +0000 (21:18 +0000)
committerStefan Fritsch <sf@apache.org>
Tue, 14 Feb 2012 21:18:22 +0000 (21:18 +0000)
NUL-terminate the resulting string, even in case of an error. mod_cgi
and mod_cgid try to log incomplete output from CGI scripts.

git-svn-id: https://svn.apache.org/repos/asf/httpd/httpd/trunk@1244211 13f79535-47bb-0310-9956-ffa450edef68

server/util_script.c

index 3f7d847a7de169387b89a465be8f24d13bcac01a..18c4aea4ca46329f7bd627a61f3ed8f466d5412e 100644 (file)
@@ -682,6 +682,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;
@@ -738,8 +739,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;