summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaiki Ueno <ueno@gnu.org>2021-11-01 16:46:50 +0100
committerDaiki Ueno <ueno@gnu.org>2021-11-03 07:28:43 +0100
commit1971491c722ebbedf06b5e6727caea407f7217d9 (patch)
treecb5d3ffb3bff4d0c8ba259461c12104a3872b8ef
parentfe9d2be0d251bc7a3e1fd7d7b59e1dbf23bae8a1 (diff)
downloadgnutls-1971491c722ebbedf06b5e6727caea407f7217d9.tar.gz
Revert "priority: fix potential race in reloading system-wide config"
This reverts commit 890c6937a3cfb4a0704bc815324221ec4cb89840. Considering the entire logic around reloading the config file, the fix was suboptimal. Signed-off-by: Daiki Ueno <ueno@gnu.org>
-rw-r--r--lib/priority.c21
1 files changed, 6 insertions, 15 deletions
diff --git a/lib/priority.c b/lib/priority.c
index cdda72d2ca..55d68d734c 100644
--- a/lib/priority.c
+++ b/lib/priority.c
@@ -39,7 +39,6 @@
#include "profiles.h"
#include "c-strcase.h"
#include "inih/ini.h"
-#include "locks.h"
#include "profiles.h"
#include "name_val_array.h"
@@ -1001,8 +1000,6 @@ static void dummy_func(gnutls_priority_t c)
#include <priority_options.h>
static gnutls_certificate_verification_profiles_t system_wide_verification_profile = GNUTLS_PROFILE_UNKNOWN;
-/* Lock for updating system_wide_priority_strings{,_init} */
-GNUTLS_STATIC_MUTEX(system_wide_priority_strings_mutex);
static name_val_array_t system_wide_priority_strings = NULL;
static unsigned system_wide_priority_strings_init = 0;
static unsigned system_wide_default_priority_string = 0;
@@ -1314,29 +1311,27 @@ static void _gnutls_update_system_priorities(void)
struct stat sb;
FILE *fp;
- GNUTLS_STATIC_MUTEX_LOCK(system_wide_priority_strings_mutex);
-
if (stat(system_priority_file, &sb) < 0) {
_gnutls_debug_log("cfg: unable to access: %s: %d\n",
system_priority_file, errno);
- goto out;
+ return;
}
if (system_wide_priority_strings_init != 0 &&
sb.st_mtime == system_priority_last_mod) {
_gnutls_debug_log("cfg: system priority %s has not changed\n",
system_priority_file);
- goto out;
+ return;
}
- _name_val_array_clear(&system_wide_priority_strings);
- system_wide_priority_strings_init = 0;
+ if (system_wide_priority_strings_init != 0)
+ _name_val_array_clear(&system_wide_priority_strings);
fp = fopen(system_priority_file, "re");
if (fp == NULL) {
_gnutls_debug_log("cfg: unable to open: %s: %d\n",
system_priority_file, errno);
- goto out;
+ return;
}
ret = ini_parse_file(fp, cfg_ini_handler, NULL);
fclose(fp);
@@ -1345,7 +1340,7 @@ static void _gnutls_update_system_priorities(void)
system_priority_file, ret);
if (fail_on_invalid_config)
exit(1);
- goto out;
+ return;
}
_gnutls_debug_log("cfg: loaded system priority %s mtime %lld\n",
@@ -1353,9 +1348,6 @@ static void _gnutls_update_system_priorities(void)
(unsigned long long)sb.st_mtime);
system_priority_last_mod = sb.st_mtime;
-
- out:
- GNUTLS_STATIC_MUTEX_UNLOCK(system_wide_priority_strings_mutex);
}
void _gnutls_load_system_priorities(void)
@@ -1376,7 +1368,6 @@ void _gnutls_load_system_priorities(void)
void _gnutls_unload_system_priorities(void)
{
_name_val_array_clear(&system_wide_priority_strings);
- system_wide_priority_strings_init = 0;
_clear_default_system_priority();
system_priority_last_mod = 0;
}