Download | Plain Text | Line Numbers


--- server/util.c.orig	2013-05-28 23:17:53.000000000 +0200
+++ server/util.c	2013-12-19 02:38:44.994088605 +0100
@@ -968,7 +968,7 @@
 /* Read one line from open ap_configfile_t, strip LF, increase line number */
 /* If custom handler does not define a getstr() function, read char by char */
 static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
-                                        ap_configfile_t *cfp)
+                                        ap_configfile_t *cfp, int buf_grown)
 {
     apr_status_t rc;
     /* If a "get string" function is defined, use it */
@@ -999,11 +999,11 @@
              */
             cp = cbuf;
             cp += strlen(cp);
-            if (cp > cbuf && cp[-1] == LF) {
+            if ((buf_grown || cp > cbuf) && cp[-1] == LF) {
                 cp--;
-                if (cp > cbuf && cp[-1] == CR)
+                if ((buf_grown || cp > cbuf) && cp[-1] == CR)
                     cp--;
-                if (cp > cbuf && cp[-1] == '\\') {
+                if ((buf_grown || cp > cbuf) && cp[-1] == '\\') {
                     cp--;
                     /*
                      * line continuation requested -
@@ -1043,7 +1043,7 @@
             if (c == LF) {
                 ++cfp->line_number;
                 /* check for line continuation */
-                if (i > 0 && buf[i-1] == '\\') {
+                if ((buf_grown || i > 0) && buf[i-1] == '\\') {
                     i--;
                     continue;
                 }
@@ -1089,7 +1089,7 @@
 AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize,
                                         ap_configfile_t *cfp)
 {
-    apr_status_t rc = ap_cfg_getline_core(buf, bufsize, cfp);
+    apr_status_t rc = ap_cfg_getline_core(buf, bufsize, cfp, 0);
     if (rc == APR_SUCCESS)
         cfg_trim_line(buf);
     return rc;
@@ -1116,7 +1116,8 @@
     }
 
     for (;;) {
-        rc = ap_cfg_getline_core(vb->buf + vb->strlen, vb->avail - vb->strlen, cfp);
+        rc = ap_cfg_getline_core(vb->buf + vb->strlen, vb->avail - vb->strlen,
+                                 cfp, vb->strlen > 0);
         if (rc == APR_ENOSPC || rc == APR_SUCCESS)
             vb->strlen += strlen(vb->buf + vb->strlen);
         if (rc != APR_ENOSPC)