~ubuntu-branches/ubuntu/precise/autofs5/precise

« back to all changes in this revision

Viewing changes to debian/patches/autofs-5.0.5-more-code-analysis-corrections.patch

  • Committer: Bazaar Package Importer
  • Author(s): Chuck Short
  • Date: 2011-07-03 14:35:46 UTC
  • mfrom: (1.1.3 upstream)
  • Revision ID: james.westby@ubuntu.com-20110703143546-nej26krjij0rf792
Tags: 5.0.6-0ubuntu1
* New upstream release:
  - Dropped upstream patches 
  - Refreshed debian/patches/17ld.patch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
autofs-5.0.5 - more code analysis corrections (and fix a typo in an init script)
2
 
 
3
 
From: Jeff Moyer <jmoyer@redhat.com>
4
 
 
5
 
- fix an obvious type in Redhat init script.
6
 
- don't call ldap_msgfree when result pointer is null.
7
 
- check return of ldap_parse_result as pointers will be invalid on fail.
8
 
- get rid of a bogus assignment in defaults_free_searchdns.
9
 
- get rid of unused optlen variable in parse_sun.c.
10
 
- check return status of stat(2) in do_mount_direct().
11
 
- get rid of unused name variable in master_add_map_source().
12
 
- check return from ops->askumount() in expire_cleanup().
13
 
- in mount_autofs.c:mount_mount(), don't increment val since we never
14
 
  look at it again.
15
 
- in autofs_sasl_dispose() ctxt must always be valid or we would have
16
 
  a much bigger problem.
17
 
- in st_start_handler() and alarm_start_handler() it is possible for
18
 
  pthread_attr_destroy() to be called with a NULL pointer.
19
 
- we could end up with a non-null result pointer after a failed call to
20
 
  ldap_search_s(), well maybe, so check for it anyway.
21
 
 
22
 
Signed-off-by: Jeff Moyer <jmoyer@redhat.com>
23
 
---
24
 
 
25
 
 CHANGELOG              |    1 +
26
 
 daemon/direct.c        |    2 +-
27
 
 daemon/state.c         |    5 +++--
28
 
 lib/alarm.c            |    3 ++-
29
 
 lib/defaults.c         |    1 -
30
 
 lib/master.c           |    6 +-----
31
 
 modules/cyrus-sasl.c   |    2 +-
32
 
 modules/lookup_ldap.c  |   13 +++++++++++--
33
 
 modules/mount_autofs.c |    2 +-
34
 
 modules/parse_sun.c    |    3 +--
35
 
 redhat/autofs.init.in  |    2 +-
36
 
 11 files changed, 23 insertions(+), 17 deletions(-)
37
 
 
38
 
 
39
 
diff --git a/CHANGELOG b/CHANGELOG
40
 
index 23351c8..b9b1602 100644
41
 
--- a/CHANGELOG
42
 
+++ b/CHANGELOG
43
 
@@ -5,6 +5,7 @@
44
 
 - add mount wait timeout parameter.
45
 
 - special case cifs escapes.
46
 
 - fix compile fail with when LDAP is excluded.
47
 
+- more code analysis corrections (and fix a typo in an init script).
48
 
 
49
 
 03/09/2009 autofs-5.0.5
50
 
 -----------------------
51
 
diff --git a/daemon/direct.c b/daemon/direct.c
52
 
index 0c78627..9b4e57b 100644
53
 
--- a/daemon/direct.c
54
 
+++ b/daemon/direct.c
55
 
@@ -1245,7 +1245,7 @@ static void *do_mount_direct(void *arg)
56
 
        }
57
 
 
58
 
        status = stat(mt.name, &st);
59
 
-       if (!S_ISDIR(st.st_mode) || st.st_dev != mt.dev) {
60
 
+       if (status != 0 || !S_ISDIR(st.st_mode) || st.st_dev != mt.dev) {
61
 
                error(ap->logopt,
62
 
                     "direct trigger not valid or already mounted %s",
63
 
                     mt.name);
64
 
diff --git a/daemon/state.c b/daemon/state.c
65
 
index 71af46a..27bc6de 100644
66
 
--- a/daemon/state.c
67
 
+++ b/daemon/state.c
68
 
@@ -160,7 +160,7 @@ void expire_cleanup(void *arg)
69
 
                         * been signaled to shutdown.
70
 
                         */
71
 
                        rv = ops->askumount(ap->logopt, ap->ioctlfd, &idle);
72
 
-                       if (!idle && !ap->shutdown) {
73
 
+                       if (!rv && !idle && !ap->shutdown) {
74
 
                                next = ST_READY;
75
 
                                if (!ap->submount)
76
 
                                        alarm_add(ap, ap->exp_runfreq);
77
 
@@ -1198,7 +1198,8 @@ int st_start_handler(void)
78
 
 
79
 
        status = pthread_create(&thid, pattrs, st_queue_handler, NULL);
80
 
 
81
 
-       pthread_attr_destroy(pattrs);
82
 
+       if (pattrs)
83
 
+               pthread_attr_destroy(pattrs);
84
 
 
85
 
        return !status;
86
 
 }
87
 
diff --git a/lib/alarm.c b/lib/alarm.c
88
 
index 46df38a..f403d8f 100755
89
 
--- a/lib/alarm.c
90
 
+++ b/lib/alarm.c
91
 
@@ -239,7 +239,8 @@ int alarm_start_handler(void)
92
 
 
93
 
        status = pthread_create(&thid, pattrs, alarm_handler, NULL);
94
 
 
95
 
-       pthread_attr_destroy(pattrs);
96
 
+       if (pattrs)
97
 
+               pthread_attr_destroy(pattrs);
98
 
 
99
 
        return !status;
100
 
 }
101
 
diff --git a/lib/defaults.c b/lib/defaults.c
102
 
index 2204b18..cb8354d 100644
103
 
--- a/lib/defaults.c
104
 
+++ b/lib/defaults.c
105
 
@@ -534,7 +534,6 @@ void defaults_free_searchdns(struct ldap_searchdn *sdn)
106
 
        struct ldap_searchdn *this = sdn;
107
 
        struct ldap_searchdn *next;
108
 
 
109
 
-       next = this;
110
 
        while (this) {
111
 
                next = this->next;
112
 
                free(this->basedn);
113
 
diff --git a/lib/master.c b/lib/master.c
114
 
index e43f835..8455f40 100644
115
 
--- a/lib/master.c
116
 
+++ b/lib/master.c
117
 
@@ -152,7 +152,7 @@ master_add_map_source(struct master_mapent *entry,
118
 
 {
119
 
        struct map_source *source;
120
 
        char *ntype, *nformat;
121
 
-       const char **tmpargv, *name = NULL;
122
 
+       const char **tmpargv;
123
 
 
124
 
        source = malloc(sizeof(struct map_source));
125
 
        if (!source)
126
 
@@ -188,10 +188,6 @@ master_add_map_source(struct master_mapent *entry,
127
 
        source->argc = argc;
128
 
        source->argv = tmpargv;
129
 
 
130
 
-       /* Can be NULL for "hosts" map */
131
 
-       if (argv)
132
 
-               name = argv[0];
133
 
-
134
 
        master_source_writelock(entry);
135
 
 
136
 
        if (!entry->maps)
137
 
diff --git a/modules/cyrus-sasl.c b/modules/cyrus-sasl.c
138
 
index 828143e..92e2226 100644
139
 
--- a/modules/cyrus-sasl.c
140
 
+++ b/modules/cyrus-sasl.c
141
 
@@ -911,7 +911,7 @@ void autofs_sasl_dispose(struct lookup_context *ctxt)
142
 
 {
143
 
        int status, ret;
144
 
 
145
 
-       if (ctxt && ctxt->sasl_conn) {
146
 
+       if (ctxt->sasl_conn) {
147
 
                sasl_dispose(&ctxt->sasl_conn);
148
 
                ctxt->sasl_conn = NULL;
149
 
        }
150
 
diff --git a/modules/lookup_ldap.c b/modules/lookup_ldap.c
151
 
index f1fb9ce..d8bd169 100644
152
 
--- a/modules/lookup_ldap.c
153
 
+++ b/modules/lookup_ldap.c
154
 
@@ -389,13 +389,16 @@ static int get_query_dn(unsigned logopt, LDAP *ldap, struct lookup_context *ctxt
155
 
                                error(logopt,
156
 
                                      MODPREFIX "query failed for search dn %s: %s",
157
 
                                      this->basedn, ldap_err2string(rv));
158
 
+                               if (result) {
159
 
+                                       ldap_msgfree(result);
160
 
+                                       result = NULL;
161
 
+                               }
162
 
                        }
163
 
 
164
 
                        this = this->next;
165
 
                }
166
 
 
167
 
                if (!result) {
168
 
-                       ldap_msgfree(result);
169
 
                        error(logopt,
170
 
                              MODPREFIX "failed to find query dn under search base dns");
171
 
                        free(query);
172
 
@@ -1954,6 +1957,12 @@ do_paged:
173
 
                sp->cookie = NULL;
174
 
        }
175
 
 
176
 
+       if (rv != LDAP_SUCCESS) {
177
 
+               debug(ap->logopt,
178
 
+                     MODPREFIX "ldap_parse_result failed with %d", rv);
179
 
+               goto out_free;
180
 
+       }
181
 
+
182
 
        /*
183
 
         * Parse the page control returned to get the cookie and
184
 
         * determine whether there are more pages.
185
 
@@ -1970,8 +1979,8 @@ do_paged:
186
 
        if (returnedControls)
187
 
                ldap_controls_free(returnedControls);
188
 
 
189
 
+out_free:
190
 
        ldap_control_free(pageControl);
191
 
-
192
 
        return rv;
193
 
 }
194
 
 
195
 
diff --git a/modules/mount_autofs.c b/modules/mount_autofs.c
196
 
index afb1859..2a5d860 100644
197
 
--- a/modules/mount_autofs.c
198
 
+++ b/modules/mount_autofs.c
199
 
@@ -119,7 +119,7 @@ int mount_mount(struct autofs_point *ap, const char *root, const char *name,
200
 
                        else if (strncmp(cp, "timeout=", 8) == 0) {
201
 
                                char *val = strchr(cp, '=');
202
 
                                unsigned tout;
203
 
-                               if (val++) {
204
 
+                               if (val) {
205
 
                                        int ret = sscanf(cp, "timeout=%u", &tout);
206
 
                                        if (ret)
207
 
                                                timeout = tout;
208
 
diff --git a/modules/parse_sun.c b/modules/parse_sun.c
209
 
index db36ae2..921daf4 100644
210
 
--- a/modules/parse_sun.c
211
 
+++ b/modules/parse_sun.c
212
 
@@ -1334,7 +1334,7 @@ int parse_mount(struct autofs_point *ap, const char *name,
213
 
        char *pmapent, *options;
214
 
        const char *p;
215
 
        int mapent_len, rv = 0;
216
 
-       int optlen, cur_state;
217
 
+       int cur_state;
218
 
        int slashify = ctxt->slashify_colons;
219
 
        unsigned int append_options;
220
 
 
221
 
@@ -1389,7 +1389,6 @@ int parse_mount(struct autofs_point *ap, const char *name,
222
 
                logerr(MODPREFIX "strdup: %s", estr);
223
 
                return 1;
224
 
        }
225
 
-       optlen = strlen(options);
226
 
 
227
 
        p = skipspace(pmapent);
228
 
 
229
 
diff --git a/redhat/autofs.init.in b/redhat/autofs.init.in
230
 
index fded1d8..806302b 100644
231
 
--- a/redhat/autofs.init.in
232
 
+++ b/redhat/autofs.init.in
233
 
@@ -172,7 +172,7 @@ case "$1" in
234
 
                fi
235
 
                ;;
236
 
        *)
237
 
-               echo $"Usage: $0 {start|forcestart|stop|status|restart|orcerestart|reload|condrestart}"
238
 
+               echo $"Usage: $0 {start|forcestart|stop|status|restart|forcerestart|reload|condrestart}"
239
 
                exit 1;
240
 
                ;;
241
 
 esac