41a6c3
diff --git a/server/util.c b/server/util.c
41a6c3
index e0ba5c2..a6516d4 100644
41a6c3
--- a/server/util.c
41a6c3
+++ b/server/util.c
41a6c3
@@ -968,20 +968,20 @@ AP_DECLARE(const char *) ap_pcfg_strerror(apr_pool_t *p, ap_configfile_t *cfp,
41a6c3
 /* Read one line from open ap_configfile_t, strip LF, increase line number */
41a6c3
 /* If custom handler does not define a getstr() function, read char by char */
41a6c3
 static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
41a6c3
-                                        ap_configfile_t *cfp)
41a6c3
+                                        apr_size_t offset, ap_configfile_t *cfp)
41a6c3
 {
41a6c3
     apr_status_t rc;
41a6c3
     /* If a "get string" function is defined, use it */
41a6c3
     if (cfp->getstr != NULL) {
41a6c3
         char *cp;
41a6c3
-        char *cbuf = buf;
41a6c3
-        apr_size_t cbufsize = bufsize;
41a6c3
+        char *cbuf = buf + offset;
41a6c3
+        apr_size_t cbufsize = bufsize - offset;
41a6c3
 
41a6c3
         while (1) {
41a6c3
             ++cfp->line_number;
41a6c3
             rc = cfp->getstr(cbuf, cbufsize, cfp->param);
41a6c3
             if (rc == APR_EOF) {
41a6c3
-                if (cbuf != buf) {
41a6c3
+                if (cbuf != buf + offset) {
41a6c3
                     *cbuf = '\0';
41a6c3
                     break;
41a6c3
                 }
41a6c3
@@ -999,11 +999,11 @@ static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
41a6c3
              */
41a6c3
             cp = cbuf;
41a6c3
             cp += strlen(cp);
41a6c3
-            if (cp > cbuf && cp[-1] == LF) {
41a6c3
+            if (cp > buf && cp[-1] == LF) {
41a6c3
                 cp--;
41a6c3
-                if (cp > cbuf && cp[-1] == CR)
41a6c3
+                if (cp > buf && cp[-1] == CR)
41a6c3
                     cp--;
41a6c3
-                if (cp > cbuf && cp[-1] == '\\') {
41a6c3
+                if (cp > buf && cp[-1] == '\\') {
41a6c3
                     cp--;
41a6c3
                     /*
41a6c3
                      * line continuation requested -
41a6c3
@@ -1021,19 +1021,19 @@ static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
41a6c3
         }
41a6c3
     } else {
41a6c3
         /* No "get string" function defined; read character by character */
41a6c3
-        apr_size_t i = 0;
41a6c3
+        apr_size_t i = offset;
41a6c3
 
41a6c3
         if (bufsize < 2) {
41a6c3
             /* too small, assume caller is crazy */
41a6c3
             return APR_EINVAL;
41a6c3
         }
41a6c3
-        buf[0] = '\0';
41a6c3
+        buf[offset] = '\0';
41a6c3
 
41a6c3
         while (1) {
41a6c3
             char c;
41a6c3
             rc = cfp->getch(&c, cfp->param);
41a6c3
             if (rc == APR_EOF) {
41a6c3
-                if (i > 0)
41a6c3
+                if (i > offset)
41a6c3
                     break;
41a6c3
                 else
41a6c3
                     return APR_EOF;
41a6c3
@@ -1051,11 +1051,11 @@ static apr_status_t ap_cfg_getline_core(char *buf, apr_size_t bufsize,
41a6c3
                     break;
41a6c3
                 }
41a6c3
             }
41a6c3
-            else if (i >= bufsize - 2) {
41a6c3
-                return APR_ENOSPC;
41a6c3
-            }
41a6c3
             buf[i] = c;
41a6c3
             ++i;
41a6c3
+            if (i >= bufsize - 1) {
41a6c3
+                return APR_ENOSPC;
41a6c3
+            }
41a6c3
         }
41a6c3
         buf[i] = '\0';
41a6c3
     }
41a6c3
@@ -1089,7 +1089,7 @@ static int cfg_trim_line(char *buf)
41a6c3
 AP_DECLARE(apr_status_t) ap_cfg_getline(char *buf, apr_size_t bufsize,
41a6c3
                                         ap_configfile_t *cfp)
41a6c3
 {
41a6c3
-    apr_status_t rc = ap_cfg_getline_core(buf, bufsize, cfp);
41a6c3
+    apr_status_t rc = ap_cfg_getline_core(buf, bufsize, 0, cfp);
41a6c3
     if (rc == APR_SUCCESS)
41a6c3
         cfg_trim_line(buf);
41a6c3
     return rc;
41a6c3
@@ -1116,7 +1116,7 @@ AP_DECLARE(apr_status_t) ap_varbuf_cfg_getline(struct ap_varbuf *vb,
41a6c3
     }
41a6c3
 
41a6c3
     for (;;) {
41a6c3
-        rc = ap_cfg_getline_core(vb->buf + vb->strlen, vb->avail - vb->strlen, cfp);
41a6c3
+        rc = ap_cfg_getline_core(vb->buf, vb->avail, vb->strlen, cfp);
41a6c3
         if (rc == APR_ENOSPC || rc == APR_SUCCESS)
41a6c3
             vb->strlen += strlen(vb->buf + vb->strlen);
41a6c3
         if (rc != APR_ENOSPC)