[autofs] - add mutex call return check in defaults.c.
Ian Kent
iankent at fedoraproject.org
Mon Jul 7 04:34:06 UTC 2014
commit d7ed6c9090d083f68421413f7793e8ee233762e5
Author: Ian Kent <ikent at redhat.com>
Date: Mon Jul 7 12:33:24 2014 +0800
- add mutex call return check in defaults.c.
...add-mutex-call-return-check-in-defaults_c.patch | 203 ++++++++++++++++++++
autofs.spec | 7 +-
2 files changed, 209 insertions(+), 1 deletions(-)
---
diff --git a/autofs-5.1.0-add-mutex-call-return-check-in-defaults_c.patch b/autofs-5.1.0-add-mutex-call-return-check-in-defaults_c.patch
new file mode 100644
index 0000000..c57a909
--- /dev/null
+++ b/autofs-5.1.0-add-mutex-call-return-check-in-defaults_c.patch
@@ -0,0 +1,203 @@
+autofs-5.1.0 - add mutex call return check in defaults.c
+
+From: Ian Kent <ikent at redhat.com>
+
+Even though pthread_mutex_lock() and pthread_mutex_unlock() should
+never fail checking their return has very occassionally been useful
+and isn't consistent with the usage elsewhere.
+---
+ CHANGELOG | 1 +
+ lib/defaults.c | 55 ++++++++++++++++++++++++++++++++++---------------------
+ 2 files changed, 35 insertions(+), 21 deletions(-)
+
+diff --git a/CHANGELOG b/CHANGELOG
+index cb74c60..04eedc4 100644
+--- a/CHANGELOG
++++ b/CHANGELOG
+@@ -19,6 +19,7 @@
+ - check options length before use in parse_amd.c.
+ - fix some out of order evaluations in parse_amd.c.
+ - fix copy and paste error in dup_defaults_entry().
++- add mutex call return check in defaults.c.
+
+ 04/06/2014 autofs-5.1.0
+ =======================
+diff --git a/lib/defaults.c b/lib/defaults.c
+index 4e09c19..8d109a2 100644
+--- a/lib/defaults.c
++++ b/lib/defaults.c
+@@ -172,6 +172,19 @@ static int conf_update(const char *, const char *, const char *, unsigned long);
+ static void conf_delete(const char *, const char *);
+ static struct conf_option *conf_lookup(const char *, const char *);
+
++static void defaults_mutex_lock(void)
++{
++ int status = pthread_mutex_lock(&conf_mutex);
++ if (status)
++ fatal(status);
++}
++
++static void defaults_mutex_unlock(void)
++{
++ int status = defaults_mutex_unlock();
++ if (status)
++ fatal(status);
++}
+
+ static void message(unsigned int to_syslog, const char *msg, ...)
+ {
+@@ -254,9 +267,9 @@ static void __conf_release(void)
+
+ void defaults_conf_release(void)
+ {
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ __conf_release();
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ return;
+ }
+
+@@ -728,11 +741,11 @@ static unsigned int conf_section_exists(const char *section)
+ return 0;
+
+ ret = 0;
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(section, section);
+ if (co)
+ ret = 1;
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+
+ return ret;
+ }
+@@ -1058,7 +1071,7 @@ unsigned int defaults_read_config(unsigned int to_syslog)
+
+ conf = oldconf = NULL;
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ if (!config) {
+ if (conf_init()) {
+ message(to_syslog, "failed to init config");
+@@ -1150,7 +1163,7 @@ out:
+ fclose(conf);
+ if (oldconf)
+ fclose(oldconf);
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ return ret;
+ }
+
+@@ -1159,11 +1172,11 @@ static char *conf_get_string(const char *section, const char *name)
+ struct conf_option *co;
+ char *val = NULL;
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(section, name);
+ if (co && co->value)
+ val = strdup(co->value);
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ return val;
+ }
+
+@@ -1172,11 +1185,11 @@ static long conf_get_number(const char *section, const char *name)
+ struct conf_option *co;
+ long val = -1;
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(section, name);
+ if (co && co->value)
+ val = atol(co->value);
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ return val;
+ }
+
+@@ -1185,7 +1198,7 @@ static int conf_get_yesno(const char *section, const char *name)
+ struct conf_option *co;
+ int val = -1;
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(section, name);
+ if (co && co->value) {
+ if (isdigit(*co->value))
+@@ -1195,7 +1208,7 @@ static int conf_get_yesno(const char *section, const char *name)
+ else if (!strcasecmp(co->value, "no"))
+ val = 0;
+ }
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ return val;
+ }
+
+@@ -1272,10 +1285,10 @@ struct list_head *defaults_get_uris(void)
+ return NULL;
+ }
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(autofs_gbl_sec, NAME_LDAP_URI);
+ if (!co) {
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ free(list);
+ return NULL;
+ }
+@@ -1286,7 +1299,7 @@ struct list_head *defaults_get_uris(void)
+ add_uris(co->value, list);
+ co = co->next;
+ }
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+
+ if (list_empty(list)) {
+ free(list);
+@@ -1398,10 +1411,10 @@ struct ldap_searchdn *defaults_get_searchdns(void)
+ if (!defaults_read_config(0))
+ return NULL;
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(autofs_gbl_sec, NAME_SEARCH_BASE);
+ if (!co) {
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ return NULL;
+ }
+
+@@ -1417,7 +1430,7 @@ struct ldap_searchdn *defaults_get_searchdns(void)
+
+ new = alloc_searchdn(co->value);
+ if (!new) {
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ defaults_free_searchdns(sdn);
+ return NULL;
+ }
+@@ -1434,7 +1447,7 @@ struct ldap_searchdn *defaults_get_searchdns(void)
+
+ co = co->next;
+ }
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+
+ return sdn;
+ }
+@@ -1512,9 +1525,9 @@ int defaults_master_set(void)
+ {
+ struct conf_option *co;
+
+- pthread_mutex_lock(&conf_mutex);
++ defaults_mutex_lock();
+ co = conf_lookup(autofs_gbl_sec, NAME_MASTER_MAP);
+- pthread_mutex_unlock(&conf_mutex);
++ defaults_mutex_unlock();
+ if (co)
+ return 1;
+ return 0;
diff --git a/autofs.spec b/autofs.spec
index 37838c9..0940795 100644
--- a/autofs.spec
+++ b/autofs.spec
@@ -8,7 +8,7 @@
Summary: A tool for automatically mounting and unmounting filesystems
Name: autofs
Version: 5.1.0
-Release: 3%{?dist}
+Release: 4%{?dist}
Epoch: 1
License: GPLv2+
Group: System Environment/Daemons
@@ -33,6 +33,7 @@ Patch17: autofs-5.1.0-check-options-length-before-use-in-parse_amd_c.patch
Patch18: autofs-5.1.0-fix-some-out-of-order-evaluations-in-parse_amd_c.patch
Patch19: autofs-5.1.0-fix-copy-and-paste-error-in-dup_defaults_entry.patch
Patch20: autofs-5.1.0-fix-leak-in-parse_mount.patch
+Patch21: autofs-5.1.0-add-mutex-call-return-check-in-defaults_c.patch
Buildroot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
%if %{with_systemd}
BuildRequires: systemd-units
@@ -110,6 +111,7 @@ echo %{version}-%{release} > .version
%patch18 -p1
%patch19 -p1
%patch20 -p1
+%patch21 -p1
%build
LDFLAGS=-Wl,-z,now
@@ -202,6 +204,9 @@ fi
%dir /etc/auto.master.d
%changelog
+* Mon Jul 7 2014 Ian Kent <ikent at redhat.com> - 1:5.1.0-4
+- add mutex call return check in defaults.c.
+
* Mon Jul 7 2014 Ian Kent <ikent at redhat.com> - 1:5.1.0-3
- fix compile error in defaults.c.
- add serialization to sasl init.
More information about the scm-commits
mailing list