~ubuntu-branches/ubuntu/raring/autofs5/raring

« back to all changes in this revision

Viewing changes to debian/patches/01UPSTREAM_autofs-5.0.4-fix-map-type-info-parse-error-update.dpatch

  • Committer: Bazaar Package Importer
  • Author(s): Jan Christoph Nordholz
  • Date: 2009-08-28 21:24:14 UTC
  • mfrom: (5.1.2 squeeze)
  • Revision ID: james.westby@ubuntu.com-20090828212414-z9xvmo5kdpm26vxv
Tags: 5.0.4-3
* Fix LSB initscript header to use keywords that
  insserv knows about. Closes: #541841.
* Bump Standards version to 3.8.3.
  * Add README.source.

* Upload sponsored by Petter Reinholdtsen.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#! /bin/sh /usr/share/dpatch/dpatch-run
 
2
## 01UPSTREAM_autofs-5.0.4-fix-map-type-info-parse-error-update.patch
 
3
##
 
4
## DP: Upstream patch on top of 5.0.4.
 
5
 
 
6
@DPATCH@
 
7
autofs-5.0.4 - fix map type info parse error update
 
8
 
 
9
From: Ian Kent <raven@themaw.net>
 
10
 
 
11
Make parsing map type info more robust.
 
12
---
 
13
 
 
14
 lib/parse_subs.c |  123 +++++++++++++++++++++++++++++++++++++++++++++---------
 
15
 1 files changed, 102 insertions(+), 21 deletions(-)
 
16
 
 
17
 
 
18
diff --git a/lib/parse_subs.c b/lib/parse_subs.c
 
19
index 0608cb7..2326838 100644
 
20
--- a/lib/parse_subs.c
 
21
+++ b/lib/parse_subs.c
 
22
@@ -20,6 +20,30 @@
 
23
 #include <ctype.h>
 
24
 #include "automount.h"
 
25
 
 
26
+struct types {
 
27
+       char *type;
 
28
+       unsigned int len;
 
29
+};
 
30
+
 
31
+static struct types map_type[] = {
 
32
+       { "file", 4 },
 
33
+       { "program", 7 },
 
34
+       { "yp", 2 },
 
35
+       { "nis", 3 },
 
36
+       { "nisplus", 7 },
 
37
+       { "ldap", 4 },
 
38
+       { "ldaps", 5 },
 
39
+       { "hesiod", 6 },
 
40
+       { "userdir", 7 },
 
41
+};
 
42
+static unsigned int map_type_count = sizeof(map_type)/sizeof(struct types);
 
43
+
 
44
+static struct types format_type[] = {
 
45
+       { "sun", 3 },
 
46
+       { "hesiod", 6 },
 
47
+};
 
48
+static unsigned int format_type_count = sizeof(format_type)/sizeof(struct types);
 
49
+
 
50
 /*
 
51
  * Skip whitespace in a string; if we hit a #, consider the rest of the
 
52
  * entry a comment.
 
53
@@ -315,7 +339,7 @@ struct map_type_info *parse_map_type_info(const char *str)
 
54
 {
 
55
        struct map_type_info *info;
 
56
        char *buf, *type, *fmt, *map, *tmp;
 
57
-       int seen_colon = 0;
 
58
+       char *pos;
 
59
 
 
60
        buf = strdup(str);
 
61
        if (!buf)
 
62
@@ -328,32 +352,89 @@ struct map_type_info *parse_map_type_info(const char *str)
 
63
        }
 
64
        memset(info, 0, sizeof(struct map_type_info));
 
65
 
 
66
-       type = fmt = NULL;
 
67
+       type = fmt = map = NULL;
 
68
+
 
69
+       tmp = strchr(buf, ':');
 
70
+       if (!tmp) {
 
71
+               pos = buf;
 
72
+               while (*pos == ' ')
 
73
+                       *pos++ = '\0';
 
74
+               map = pos;
 
75
+       } else {
 
76
+               int i, j;
 
77
+
 
78
+               for (i = 0; i < map_type_count; i++) {
 
79
+                       char *m_type = map_type[i].type;
 
80
+                       unsigned int m_len = map_type[i].len;
 
81
+
 
82
+                       pos = buf;
 
83
+
 
84
+                       if (strncmp(m_type, pos, m_len))
 
85
+                               continue;
 
86
+
 
87
+                       type = pos;
 
88
+                       pos += m_len;
 
89
+
 
90
+                       if (*pos == ' ' || *pos == ':') {
 
91
+                               while (*pos == ' ')
 
92
+                                       *pos++ = '\0';
 
93
+                               if (*pos != ':') {
 
94
+                                       free(buf);
 
95
+                                       free(info);
 
96
+                                       return NULL;
 
97
+                               } else {
 
98
+                                       *pos++ = '\0';
 
99
+                                       while (*pos == ' ')
 
100
+                                               *pos++ = '\0';
 
101
+                                       map = pos;
 
102
+                                       break;
 
103
+                               }
 
104
+                       }
 
105
+
 
106
+                       if (*pos == ',') {
 
107
+                               *pos++ = '\0';
 
108
+                               for (j = 0; j < format_type_count; j++) {
 
109
+                                       char *f_type = format_type[j].type;
 
110
+                                       unsigned int f_len = format_type[j].len;
 
111
+                               
 
112
+                                       if (strncmp(f_type, pos, f_len))
 
113
+                                               continue;
 
114
+
 
115
+                                       fmt = pos;
 
116
+                                       pos += f_len;
 
117
+
 
118
+                                       if (*pos == ' ' || *pos == ':') {
 
119
+                                               while (*pos == ' ')
 
120
+                                                       *pos++ = '\0';
 
121
+                                               if (*pos != ':') {
 
122
+                                                       free(buf);
 
123
+                                                       free(info);
 
124
+                                                       return NULL;
 
125
+                                               } else {
 
126
+                                                       *pos++ = '\0';
 
127
+                                                       while (*pos == ' ')
 
128
+                                                               *pos++ = '\0';
 
129
+                                                       map = pos;
 
130
+                                                       break;
 
131
+                                               }
 
132
+                                       }
 
133
+                               }
 
134
+                       }
 
135
+               }
 
136
+
 
137
+               if (!type) {
 
138
+                       pos = buf;
 
139
+                       while (*pos == ' ')
 
140
+                               *pos++ = '\0';
 
141
+                       map = pos;
 
142
+               }
 
143
+       }
 
144
 
 
145
        /* Look for space terminator - ignore local options */
 
146
-       map = buf;
 
147
        for (tmp = buf; *tmp; tmp++) {
 
148
                if (*tmp == ' ') {
 
149
                        *tmp = '\0';
 
150
                        break;
 
151
-               } else if (!seen_colon && *tmp == ',') {
 
152
-                       type = buf;
 
153
-                       *tmp++ = '\0';
 
154
-                       fmt = tmp;
 
155
-               } else if (*tmp == ':') {
 
156
-                       seen_colon = 1;
 
157
-                       if (!fmt)
 
158
-                               type = buf;
 
159
-                       *tmp++ = '\0';
 
160
-                       map = tmp;
 
161
-               } else if (*tmp == '[') {
 
162
-                       /*
 
163
-                        * Unescaped '[' is a syntax error here as only
 
164
-                        * an ldap map with a type specified should contain
 
165
-                        * them. 
 
166
-                        */
 
167
-                       free(buf);
 
168
-                       return 0;
 
169
                }
 
170
                if (*tmp == '\\')
 
171
                        tmp++;