Remove fixed length buffer
This commit is contained in:
parent
1a251f9934
commit
2c76d8c105
@ -1,6 +1,11 @@
|
|||||||
ChangeLog for davfs2
|
ChangeLog for davfs2
|
||||||
--------------------
|
--------------------
|
||||||
|
|
||||||
|
2011-06-23 Werner Baumann (werner.baumann@onlinehome.de)
|
||||||
|
* mount_davfs.c, parse_line, read_config, read_secrets:
|
||||||
|
Remove fixed length buffer, parse config line in place
|
||||||
|
(bug #33412).
|
||||||
|
|
||||||
2011-05-27 Werner Baumann (werner.baumann@onlinehome.de)
|
2011-05-27 Werner Baumann (werner.baumann@onlinehome.de)
|
||||||
* umount_davfs.c:
|
* umount_davfs.c:
|
||||||
Missing #include "canonicalize.h"
|
Missing #include "canonicalize.h"
|
||||||
|
1
THANKS
1
THANKS
@ -55,6 +55,7 @@ Holger Librenz <me@holger-librenz.de>
|
|||||||
Reddy T. Mahesh <tmahesh@users.sourceforge.net>
|
Reddy T. Mahesh <tmahesh@users.sourceforge.net>
|
||||||
Juergen P. Messerer <messi@users.sourceforge.net>
|
Juergen P. Messerer <messi@users.sourceforge.net>
|
||||||
Arkadiusz Miskiewicz <arekm@users.sourceforge.net>
|
Arkadiusz Miskiewicz <arekm@users.sourceforge.net>
|
||||||
|
Andre Naujoks <nautsch2@googlemail.com>
|
||||||
Maik Nijhuis <manyac@users.sourceforge.net>
|
Maik Nijhuis <manyac@users.sourceforge.net>
|
||||||
Joseph Wayne Norton <natsukashi@users.sourceforge.net>
|
Joseph Wayne Norton <natsukashi@users.sourceforge.net>
|
||||||
Tim Olsen <tim@brooklynpenguin.com>
|
Tim Olsen <tim@brooklynpenguin.com>
|
||||||
|
@ -1923,11 +1923,11 @@ log_dbg_config(char *argv[], dav_args *args)
|
|||||||
it must be escaped if there is more than on '\'-character in succession.
|
it must be escaped if there is more than on '\'-character in succession.
|
||||||
Whitespace characters other than ' ' and tab must only occur at the end of
|
Whitespace characters other than ' ' and tab must only occur at the end of
|
||||||
the line.
|
the line.
|
||||||
line : the line to be parsed
|
line : the line to be parsed. It will be changed by this function.
|
||||||
parmc : the max. number of parameters. It is an error, if more than parmc
|
parmc : the max. number of parameters. It is an error, if more than parmc
|
||||||
parameters are found
|
parameters are found
|
||||||
parmv[] : the parameters found are returned in this array. They are newly
|
parmv[] : the parameters found are returned in this array. It contains
|
||||||
allocated strings and must be freed by the calling function.
|
pointers into the rearranged line parameter.
|
||||||
reurn value : the numer of parameters or -1 if an error occurs. */
|
reurn value : the numer of parameters or -1 if an error occurs. */
|
||||||
static int
|
static int
|
||||||
parse_line(char *line, int parmc, char *parmv[])
|
parse_line(char *line, int parmc, char *parmv[])
|
||||||
@ -1945,27 +1945,27 @@ parse_line(char *line, int parmc, char *parmv[])
|
|||||||
|
|
||||||
int state = SPACE;
|
int state = SPACE;
|
||||||
int parm_no = 0;
|
int parm_no = 0;
|
||||||
char buf[254];
|
char *pos = line;
|
||||||
char *pos = buf;
|
|
||||||
char *end = buf + 253;
|
|
||||||
char *p = line;
|
char *p = line;
|
||||||
|
parmv[0] = line;
|
||||||
|
|
||||||
while ((state != END) && (state != ERROR)) {
|
while (state != END) {
|
||||||
switch (state) {
|
switch (state) {
|
||||||
case SPACE:
|
case SPACE:
|
||||||
if (*p == '\0' || *p == '#' || *p == '\f' || *p == '\n'
|
if (*p == '\0' || *p == '#' || *p == '\f' || *p == '\n'
|
||||||
|| *p == '\r' || *p == '\v') {
|
|| *p == '\r' || *p == '\v') {
|
||||||
state = END;
|
state = END;
|
||||||
} else if (*p == '\"') {
|
} else if (*p == '\"') {
|
||||||
state = (parm_no < parmc) ? PARM_QUO : ERROR;
|
state = PARM_QUO;
|
||||||
} else if (*p == '\\') {
|
} else if (*p == '\\') {
|
||||||
state = (parm_no < parmc) ? PARM_ESC : ERROR;
|
state = PARM_ESC;
|
||||||
} else if (isspace(*p)) {
|
} else if (isspace(*p)) {
|
||||||
;
|
;
|
||||||
} else {
|
} else {
|
||||||
*pos++ = *p;
|
*pos++ = *p;
|
||||||
state = (parm_no < parmc) ? PARM : ERROR;
|
state = PARM;
|
||||||
}
|
}
|
||||||
|
if (parm_no >= parmc) return -1;
|
||||||
break;
|
break;
|
||||||
case SPACE_EXP:
|
case SPACE_EXP:
|
||||||
if (*p == ' ' || *p == '\t') {
|
if (*p == ' ' || *p == '\t') {
|
||||||
@ -1974,65 +1974,60 @@ parse_line(char *line, int parmc, char *parmv[])
|
|||||||
|| *p == '\r' || *p == '\v') {
|
|| *p == '\r' || *p == '\v') {
|
||||||
state = END;
|
state = END;
|
||||||
} else {
|
} else {
|
||||||
state = ERROR;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARM:
|
case PARM:
|
||||||
if (*p == '\"') {
|
if (*p == '\"') {
|
||||||
state = ERROR;
|
return -1;
|
||||||
} else if (*p == '\\') {
|
} else if (*p == '\\') {
|
||||||
state = PARM_ESC;
|
state = PARM_ESC;
|
||||||
} else if (*p == ' ' || *p == '\t') {
|
} else if (*p == ' ' || *p == '\t') {
|
||||||
parmv[parm_no++] = ne_strndup(buf, pos - buf);
|
*pos++ = '\0';
|
||||||
pos = buf;
|
parmv[++parm_no] = pos;
|
||||||
state = SPACE;
|
state = SPACE;
|
||||||
} else if (isspace(*p) || *p == '\0' || *p == '#') {
|
} else if (isspace(*p) || *p == '\0' || *p == '#') {
|
||||||
parmv[parm_no++] = ne_strndup(buf, pos - buf);
|
*pos = '\0';
|
||||||
pos = buf;
|
parm_no++;
|
||||||
state = END;
|
state = END;
|
||||||
} else {
|
} else {
|
||||||
*pos++ = *p;
|
*pos++ = *p;
|
||||||
state = (pos < end) ? PARM : ERROR;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARM_ESC:
|
case PARM_ESC:
|
||||||
if (*p == '\"' || *p == '\\' || *p == '#' || *p == ' '
|
if (*p == '\"' || *p == '\\' || *p == '#' || *p == ' '
|
||||||
|| *p == '\t') {
|
|| *p == '\t') {
|
||||||
*pos++ = *p;
|
*pos++ = *p;
|
||||||
state = (pos < end) ? PARM : ERROR;
|
state = PARM;
|
||||||
} else {
|
} else {
|
||||||
state = ERROR;
|
return -1;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARM_QUO:
|
case PARM_QUO:
|
||||||
if (*p == '\\') {
|
if (*p == '\\') {
|
||||||
state = PARM_QUO_ESC;
|
state = PARM_QUO_ESC;
|
||||||
} else if (*p == '\"') {
|
} else if (*p == '\"') {
|
||||||
parmv[parm_no++] = ne_strndup(buf, pos - buf);
|
*pos++ = '\0';
|
||||||
pos = buf;
|
parmv[++parm_no] = pos;
|
||||||
state = SPACE_EXP;
|
state = SPACE_EXP;
|
||||||
} else if (*p == '\0' || *p == '\f' || *p == '\n'
|
} else if (*p == '\0' || *p == '\f' || *p == '\n'
|
||||||
|| *p == '\r' || *p == '\v') {
|
|| *p == '\r' || *p == '\v') {
|
||||||
state = ERROR;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
*pos++ = *p;
|
*pos++ = *p;
|
||||||
state = (pos < end) ? PARM_QUO : ERROR;
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case PARM_QUO_ESC:
|
case PARM_QUO_ESC:
|
||||||
if (*p == '\"' || *p == '\\') {
|
if (*p == '\"' || *p == '\\') {
|
||||||
*pos++ = *p;
|
*pos++ = *p;
|
||||||
state = (pos < end) ? PARM_QUO : ERROR;
|
state = PARM_QUO;
|
||||||
} else if (*p == '\0' || *p == '\f' || *p == '\n'
|
} else if (*p == '\0' || *p == '\f' || *p == '\n'
|
||||||
|| *p == '\r' || *p == '\v') {
|
|| *p == '\r' || *p == '\v') {
|
||||||
state = ERROR;
|
return -1;
|
||||||
} else {
|
} else {
|
||||||
*pos++ = '\\';
|
*pos++ = '\\';
|
||||||
state = (pos < end) ? PARM_QUO : ERROR;
|
*pos++ = *p;
|
||||||
if (state == PARM_QUO) {
|
state = PARM_QUO;
|
||||||
*pos++ = *p;
|
|
||||||
state = (pos < end) ? PARM_QUO : ERROR;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -2040,17 +2035,9 @@ parse_line(char *line, int parmc, char *parmv[])
|
|||||||
}
|
}
|
||||||
|
|
||||||
int i;
|
int i;
|
||||||
if (state == END) {
|
for (i = parm_no; i < parmc; i++)
|
||||||
for (i = parm_no; i < parmc; i++)
|
parmv[i] = NULL;
|
||||||
parmv[i] = NULL;
|
return parm_no;
|
||||||
return parm_no;
|
|
||||||
} else {
|
|
||||||
for (i = 0; i < parm_no; i++) {
|
|
||||||
free(parmv[i]);
|
|
||||||
parmv[i] = NULL;
|
|
||||||
}
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -2247,8 +2234,6 @@ read_config(dav_args *args, const char * filename, int system)
|
|||||||
_("malformed line"));
|
_("malformed line"));
|
||||||
}
|
}
|
||||||
|
|
||||||
for (parmc = 0; parmc < count; parmc++)
|
|
||||||
free(parmv[parmc]);
|
|
||||||
length = getline(&line, &n, file);
|
length = getline(&line, &n, file);
|
||||||
lineno++;
|
lineno++;
|
||||||
}
|
}
|
||||||
@ -2426,10 +2411,6 @@ read_secrets(dav_args *args, const char *filename)
|
|||||||
if (path) free(path);
|
if (path) free(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (parmc = 0; parmc < count; parmc++) {
|
|
||||||
memset(parmv[parmc], '\0', strlen(parmv[parmc]));
|
|
||||||
free(parmv[parmc]);
|
|
||||||
}
|
|
||||||
memset(line, '\0', strlen(line));
|
memset(line, '\0', strlen(line));
|
||||||
length = getline(&line, &n, file);
|
length = getline(&line, &n, file);
|
||||||
lineno++;
|
lineno++;
|
||||||
|
Loading…
Reference in New Issue
Block a user