1 autofs-5.0.4 - fix map type info parse error update
3 From: Ian Kent <raven@themaw.net>
5 Make parsing map type info more robust.
8 lib/parse_subs.c | 123 +++++++++++++++++++++++++++++++++++++++++++++---------
9 1 files changed, 102 insertions(+), 21 deletions(-)
12 diff --git a/lib/parse_subs.c b/lib/parse_subs.c
13 index 0608cb7..2326838 100644
14 --- a/lib/parse_subs.c
15 +++ b/lib/parse_subs.c
18 #include "automount.h"
25 +static struct types map_type[] = {
36 +static unsigned int map_type_count = sizeof(map_type)/sizeof(struct types);
38 +static struct types format_type[] = {
42 +static unsigned int format_type_count = sizeof(format_type)/sizeof(struct types);
45 * Skip whitespace in a string; if we hit a #, consider the rest of the
47 @@ -315,7 +339,7 @@ struct map_type_info *parse_map_type_info(const char *str)
49 struct map_type_info *info;
50 char *buf, *type, *fmt, *map, *tmp;
56 @@ -328,32 +352,89 @@ struct map_type_info *parse_map_type_info(const char *str)
58 memset(info, 0, sizeof(struct map_type_info));
61 + type = fmt = map = NULL;
63 + tmp = strchr(buf, ':');
72 + for (i = 0; i < map_type_count; i++) {
73 + char *m_type = map_type[i].type;
74 + unsigned int m_len = map_type[i].len;
78 + if (strncmp(m_type, pos, m_len))
84 + if (*pos == ' ' || *pos == ':') {
102 + for (j = 0; j < format_type_count; j++) {
103 + char *f_type = format_type[j].type;
104 + unsigned int f_len = format_type[j].len;
106 + if (strncmp(f_type, pos, f_len))
112 + if (*pos == ' ' || *pos == ':') {
113 + while (*pos == ' ')
121 + while (*pos == ' ')
133 + while (*pos == ' ')
139 /* Look for space terminator - ignore local options */
141 for (tmp = buf; *tmp; tmp++) {
145 - } else if (!seen_colon && *tmp == ',') {
149 - } else if (*tmp == ':') {
155 - } else if (*tmp == '[') {
157 - * Unescaped '[' is a syntax error here as only
158 - * an ldap map with a type specified should contain