diff options
author | Simon Rozman | 2019-02-24 19:12:52 +0100 |
---|---|---|
committer | Gert Doering | 2019-02-28 15:46:24 +0100 |
commit | f75351da2974dac10baca5fa83c18be7f27c73cf (patch) | |
tree | b697d0a5edfe30591840e8edea9ae71b312f98c7 /src/openvpnmsica/dllmain.c | |
parent | a35d517f4893b3967783ad7926a7edd08f9f59d3 (diff) | |
download | openvpn-f75351da2974dac10baca5fa83c18be7f27c73cf.zip openvpn-f75351da2974dac10baca5fa83c18be7f27c73cf.tar.gz |
Disambiguate thread local storage references from TLS
Since OpenVPN is security software, "TLS" usually stands for Transport
Layer Security.
Furthermore, repetitive copy&paste code was refactored using a macro.
This patch follows Gert's recommendations from [openvpn-devel].
Signed-off-by: Simon Rozman <simon@rozman.si>
Message-ID: <20190117155829.GA92142@greenie.muc.de>
Acked-by: Gert Doering <gert@greenie.muc.de>
Message-Id: <20190224181252.43996-1-simon@rozman.si
20190117155829.GA92142@greenie.muc.de>
URL: https://www.mail-archive.com/openvpn-devel@lists.sourceforge.net/msg18230.html
Signed-off-by: Gert Doering <gert@greenie.muc.de>
Diffstat (limited to 'src/openvpnmsica/dllmain.c')
-rw-r--r-- | src/openvpnmsica/dllmain.c | 30 |
1 files changed, 15 insertions, 15 deletions
diff --git a/src/openvpnmsica/dllmain.c b/src/openvpnmsica/dllmain.c index 50231e4..5f5092a 100644 --- a/src/openvpnmsica/dllmain.c +++ b/src/openvpnmsica/dllmain.c @@ -36,7 +36,7 @@ #include <tchar.h> -DWORD openvpnmsica_tlsidx_session = TLS_OUT_OF_INDEXES; +DWORD openvpnmsica_thread_data_idx = TLS_OUT_OF_INDEXES; /** @@ -54,9 +54,9 @@ DllMain( switch (dwReason) { case DLL_PROCESS_ATTACH: - /* Allocate TLS index. */ - openvpnmsica_tlsidx_session = TlsAlloc(); - if (openvpnmsica_tlsidx_session == TLS_OUT_OF_INDEXES) + /* Allocate thread local storage index. */ + openvpnmsica_thread_data_idx = TlsAlloc(); + if (openvpnmsica_thread_data_idx == TLS_OUT_OF_INDEXES) { return FALSE; } @@ -64,25 +64,25 @@ DllMain( case DLL_THREAD_ATTACH: { - /* Create TLS data. */ - struct openvpnmsica_tls_data *s = (struct openvpnmsica_tls_data *)malloc(sizeof(struct openvpnmsica_tls_data)); - memset(s, 0, sizeof(struct openvpnmsica_tls_data)); - TlsSetValue(openvpnmsica_tlsidx_session, s); + /* Create thread local storage data. */ + struct openvpnmsica_thread_data *s = (struct openvpnmsica_thread_data *)malloc(sizeof(struct openvpnmsica_thread_data)); + memset(s, 0, sizeof(struct openvpnmsica_thread_data)); + TlsSetValue(openvpnmsica_thread_data_idx, s); break; } case DLL_PROCESS_DETACH: - if (openvpnmsica_tlsidx_session != TLS_OUT_OF_INDEXES) + if (openvpnmsica_thread_data_idx != TLS_OUT_OF_INDEXES) { - /* Free TLS data and TLS index. */ - free(TlsGetValue(openvpnmsica_tlsidx_session)); - TlsFree(openvpnmsica_tlsidx_session); + /* Free thread local storage data and index. */ + free(TlsGetValue(openvpnmsica_thread_data_idx)); + TlsFree(openvpnmsica_thread_data_idx); } break; case DLL_THREAD_DETACH: - /* Free TLS data. */ - free(TlsGetValue(openvpnmsica_tlsidx_session)); + /* Free thread local storage data. */ + free(TlsGetValue(openvpnmsica_thread_data_idx)); break; } @@ -105,7 +105,7 @@ x_msg_va(const unsigned int flags, const char *format, va_list arglist) /* Secure last error before it is overridden. */ DWORD dwResult = (flags & M_ERRNO) != 0 ? GetLastError() : ERROR_SUCCESS; - struct openvpnmsica_tls_data *s = (struct openvpnmsica_tls_data *)TlsGetValue(openvpnmsica_tlsidx_session); + struct openvpnmsica_thread_data *s = (struct openvpnmsica_thread_data *)TlsGetValue(openvpnmsica_thread_data_idx); if (s->hInstall == 0) { /* No MSI session, no fun. */ |