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