Change in openvpn[master]: Replace strtok with strtok_r
A message that is not in the archive (sent off-list or not yet received): gerrit.1778963232000.I70560efd113308b7377424127eb2c1da4266371a@gerrit.openvpn.net
plaisthos has uploaded this change for review. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This dos not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
---
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
4 files changed, 15 insertions(+), 10 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/1679/1
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
Signature · 11 lines
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email Gerrit-MessageType: newchange Gerrit-Project: openvpn Gerrit-Branch: master Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a Gerrit-Change-Number: 1679 Gerrit-PatchSet: 1 Gerrit-Owner: plaisthos <[email protected]> Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
plaisthos has uploaded a new patch set (#2). ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This dos not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
---
M CMakeLists.txt
M configure.ac
A src/compat/compat-strtok_r.c
M src/compat/compat.h
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
8 files changed, 123 insertions(+), 11 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/1679/2
CMakeLists.txt +1 -0
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 2
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
plaisthos has uploaded a new patch set (#3). ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This dos not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
---
M CMakeLists.txt
M configure.ac
M src/compat/Makefile.am
A src/compat/compat-strtok_r.c
M src/compat/compat.h
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
M tests/unit_tests/openvpn/Makefile.am
10 files changed, 130 insertions(+), 13 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/1679/3
CMakeLists.txt +4 -1
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
@@ -413,6 +414,7 @@ src/compat/compat-dirname.c src/compat/compat-gettimeofday.c src/compat/compat-strsep.c + src/compat/compat-strtok_r.c src/openvpn/argv.c src/openvpn/argv.h src/openvpn/base64.c
@@ -733,7 +735,8 @@ src/openvpn/platform.c src/openvpn/win32-util.c src/compat/compat-gettimeofday.c - ) + src/compat/compat-strsep.c + ) add_library_deps(${test_name}) target_link_libraries(${test_name} PUBLIC ${CMOCKA_LIBRARIES})
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ compat-basename.c \ compat-gettimeofday.c \ compat-daemon.c \ - compat-strsep.c + compat-strsep.c \ + compat-strtok_r.c
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
tests/unit_tests/openvpn/Makefile.am +2 -0
@@ -107,6 +107,7 @@ $(top_srcdir)/src/openvpn/base64.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/crypto.c \ $(top_srcdir)/src/openvpn/cryptoapi.c \ $(top_srcdir)/src/openvpn/crypto_epoch.c \
@@ -345,6 +346,7 @@ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/ssl_util.c mbuf_testdriver_CFLAGS = \
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 3
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
plaisthos has uploaded a new patch set (#4). ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This dos not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
---
M CMakeLists.txt
M configure.ac
M src/compat/Makefile.am
A src/compat/compat-strtok_r.c
M src/compat/compat.h
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
M tests/unit_tests/openvpn/Makefile.am
10 files changed, 130 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/1679/4
CMakeLists.txt +4 -0
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
@@ -413,6 +414,7 @@ src/compat/compat-dirname.c src/compat/compat-gettimeofday.c src/compat/compat-strsep.c + src/compat/compat-strtok_r.c src/openvpn/argv.c src/openvpn/argv.h src/openvpn/base64.c
@@ -733,6 +735,8 @@ src/openvpn/platform.c src/openvpn/win32-util.c src/compat/compat-gettimeofday.c + src/compat/compat-strsep.c + src/compat/compat-strtok_r.c ) add_library_deps(${test_name})
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ compat-basename.c \ compat-gettimeofday.c \ compat-daemon.c \ - compat-strsep.c + compat-strsep.c \ + compat-strtok_r.c
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
tests/unit_tests/openvpn/Makefile.am +2 -0
@@ -107,6 +107,7 @@ $(top_srcdir)/src/openvpn/base64.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/crypto.c \ $(top_srcdir)/src/openvpn/cryptoapi.c \ $(top_srcdir)/src/openvpn/crypto_epoch.c \
@@ -345,6 +346,7 @@ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/ssl_util.c mbuf_testdriver_CFLAGS = \
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/options_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1679/comment/0fcc165a_f8562a96?usp=email :
PS4, Line 51: char *lasts;
The Linux man page for strtok_r warns "On some implementations, *saveptr is required to be NULL on the first call to strtok_r() that is being used to parse str." So maybe we should initialize it to NULL instead of giving it uninitialized?
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Comment-Date: Wed, 20 May 2026 15:48:21 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Patch Set 4:
(1 comment)
File src/openvpn/options_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1679/comment/9ddf5d84_137b19de?usp=email :
PS4, Line 51: char *lasts;
Quoted 1 line
The Linux man page for
strtok_rwarns "On some implementations, *saveptr is required to be NULL on t […]
Sounds good. Will amend the patch to do that.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 4
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Comment-Date: Wed, 20 May 2026 16:01:56 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld.
plaisthos has uploaded a new patch set (#5). ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This dos not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
---
M CMakeLists.txt
M configure.ac
M src/compat/Makefile.am
A src/compat/compat-strtok_r.c
M src/compat/compat.h
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
M tests/unit_tests/openvpn/Makefile.am
10 files changed, 130 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/1679/5
CMakeLists.txt +4 -0
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
@@ -413,6 +414,7 @@ src/compat/compat-dirname.c src/compat/compat-gettimeofday.c src/compat/compat-strsep.c + src/compat/compat-strtok_r.c src/openvpn/argv.c src/openvpn/argv.h src/openvpn/base64.c
@@ -733,6 +735,8 @@ src/openvpn/platform.c src/openvpn/win32-util.c src/compat/compat-gettimeofday.c + src/compat/compat-strsep.c + src/compat/compat-strtok_r.c ) add_library_deps(${test_name})
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ compat-basename.c \ compat-gettimeofday.c \ compat-daemon.c \ - compat-strsep.c + compat-strsep.c \ + compat-strtok_r.c
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts =NULL ; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts =NULL ; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts =NULL ; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts =NULL ; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts =NULL ; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
tests/unit_tests/openvpn/Makefile.am +2 -0
@@ -107,6 +107,7 @@ $(top_srcdir)/src/openvpn/base64.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/crypto.c \ $(top_srcdir)/src/openvpn/cryptoapi.c \ $(top_srcdir)/src/openvpn/crypto_epoch.c \
@@ -345,6 +346,7 @@ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/ssl_util.c mbuf_testdriver_CFLAGS = \
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: flichtenheld.
plaisthos has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Patch Set 5:
(1 comment)
File src/openvpn/options_util.c:
http://gerrit.openvpn.net/c/openvpn/+/1679/comment/be9f75b1_d2478461?usp=email :
PS4, Line 51: char *lasts;
Quoted 1 line
Sounds good. Will amend the patch to do that.
Done
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: flichtenheld <[email protected]>
Gerrit-Comment-Date: Wed, 20 May 2026 16:18:20 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
Comment-In-Reply-To: plaisthos <[email protected]>
Comment-In-Reply-To: flichtenheld <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Patch Set 5:
(1 comment)
Patchset:
PS5:
LGTM. However, I have not reviewed the compat implementation.
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-CC: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Comment-Date: Wed, 20 May 2026 16:33:24 +0000
Gerrit-HasComments: Yes
Gerrit-Has-Labels: No
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
Attention is currently required from: plaisthos.
flichtenheld has posted comments on this change by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Patch Set 5: Code-Review+2
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: comment
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 5
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
Gerrit-Attention: plaisthos <[email protected]>
Gerrit-Comment-Date: Wed, 20 May 2026 16:33:35 +0000
Gerrit-HasComments: No
Gerrit-Has-Labels: Yes
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
PATCH v5 1/1 Replace strtok with strtok_r
In reply to a message not in the archiveFrom: Arne Schwabe <[email protected]>
This dos not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1679
---
This change was reviewed on Gerrit and approved by at least one developer. I request to merge it to master.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1679
This mail reflects revision 5 of this Change.
Acked-by according to Gerrit (reflected above):
Frank Lichtenheld <[email protected]>
CMakeLists.txt +4 -0
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
@@ -413,6 +414,7 @@ src/compat/compat-dirname.c src/compat/compat-gettimeofday.c src/compat/compat-strsep.c + src/compat/compat-strtok_r.c src/openvpn/argv.c src/openvpn/argv.h src/openvpn/base64.c
@@ -733,6 +735,8 @@ src/openvpn/platform.c src/openvpn/win32-util.c src/compat/compat-gettimeofday.c + src/compat/compat-strsep.c + src/compat/compat-strtok_r.c ) add_library_deps(${test_name})
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ compat-basename.c \ compat-gettimeofday.c \ compat-daemon.c \ - compat-strsep.c + compat-strsep.c \ + compat-strtok_r.c
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts =NULL ; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts =NULL ; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts =NULL ; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts =NULL ; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts =NULL ; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
tests/unit_tests/openvpn/Makefile.am +2 -0
@@ -107,6 +107,7 @@ $(top_srcdir)/src/openvpn/base64.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/crypto.c \ $(top_srcdir)/src/openvpn/cryptoapi.c \ $(top_srcdir)/src/openvpn/crypto_epoch.c \
@@ -345,6 +346,7 @@ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/ssl_util.c mbuf_testdriver_CFLAGS = \
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
[Openvpn-devel] [PATCH applied] Re: Replace strtok with strtok_r
"Code proofing for the future", or so. After a bit of discussion it was decided that this only impacts -Werror on Android, and the Android app is only built from master, so it does not need to go to release/2.7 ("for now").
Passed all BB tests and a full t_server run, plus good stare-at-code and a "make distcheck" (= new files added tend to be forgotten...)
Your patch has been applied to the master branch.
commit 27df276eabdf87ad97ab88e8e84cc53d2bbc59c8 (master)
Author: Arne Schwabe Date: Wed Jul 8 17:31:07 2026 +0200
Replace strtok with strtok_r
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1679
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg37538.html
--
kind regards,
Gert Doering
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
cron2 has uploaded a new patch set (#6) to the change originally created by plaisthos. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
The following approvals got outdated and were removed:
Code-Review+2 by flichtenheld
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This does not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1679
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg37538.html
---
M CMakeLists.txt
M configure.ac
M src/compat/Makefile.am
A src/compat/compat-strtok_r.c
M src/compat/compat.h
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
M tests/unit_tests/openvpn/Makefile.am
10 files changed, 130 insertions(+), 12 deletions(-)
git pull ssh://gerrit.openvpn.net:29418/openvpn refs/changes/79/1679/6
CMakeLists.txt +4 -0
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
@@ -423,6 +424,7 @@ src/compat/compat-dirname.c src/compat/compat-gettimeofday.c src/compat/compat-strsep.c + src/compat/compat-strtok_r.c src/openvpn/argv.c src/openvpn/argv.h src/openvpn/base64.c
@@ -743,6 +745,8 @@ src/openvpn/platform.c src/openvpn/win32-util.c src/compat/compat-gettimeofday.c + src/compat/compat-strsep.c + src/compat/compat-strtok_r.c ) add_library_deps(${test_name})
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ compat-basename.c \ compat-gettimeofday.c \ compat-daemon.c \ - compat-strsep.c + compat-strsep.c \ + compat-strtok_r.c
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts =NULL ; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts =NULL ; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts =NULL ; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts =NULL ; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts =NULL ; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
tests/unit_tests/openvpn/Makefile.am +2 -0
@@ -107,6 +107,7 @@ $(top_srcdir)/src/openvpn/base64.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/crypto.c \ $(top_srcdir)/src/openvpn/cryptoapi.c \ $(top_srcdir)/src/openvpn/crypto_epoch.c \
@@ -345,6 +346,7 @@ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/ssl_util.c mbuf_testdriver_CFLAGS = \
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: newpatchset
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel
cron2 has submitted this change. ( http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email )
Change subject: Replace strtok with strtok_r
......................................................................
Replace strtok with strtok_r
This does not change anything in our source code but makes compiling with newer Android NDKs (version 30 pre release) -Werror safe again as it has started throwing warning on this.
The compat version is taken from current FreeBSD (commit dc36d6f9bb1) src/lib/libc/string/strtok.c and reformatted to our clang standard.
Gerrit URL: https://gerrit.openvpn.net/c/openvpn/+/1679
Message-Id: <[email protected]>
URL: https://www.mail-archive.com/[email protected]/msg37538.html
---
M CMakeLists.txt
M configure.ac
M src/compat/Makefile.am
A src/compat/compat-strtok_r.c
M src/compat/compat.h
M src/openvpn/options_util.c
M src/openvpn/ssl_mbedtls.c
M src/openvpn/ssl_ncp.c
M src/openvpn/ssl_verify.c
M tests/unit_tests/openvpn/Makefile.am
10 files changed, 130 insertions(+), 12 deletions(-)
CMakeLists.txt +4 -0
@@ -248,6 +248,7 @@ check_symbol_exists(chsize io.h HAVE_CHSIZE) check_symbol_exists(getrlimit sys/resource.h HAVE_GETRLIMIT) check_symbol_exists(strsep string.h HAVE_STRSEP) +check_symbol_exists(strtok_r string.h HAVE_STRTOK_R) # Some OS (e.g. FreeBSD) need some basic headers to allow # including network headers
@@ -423,6 +424,7 @@ src/compat/compat-dirname.c src/compat/compat-gettimeofday.c src/compat/compat-strsep.c + src/compat/compat-strtok_r.c src/openvpn/argv.c src/openvpn/argv.h src/openvpn/base64.c
@@ -743,6 +745,8 @@ src/openvpn/platform.c src/openvpn/win32-util.c src/compat/compat-gettimeofday.c + src/compat/compat-strsep.c + src/compat/compat-strtok_r.c ) add_library_deps(${test_name})
configure.ac +1 -1
@@ -568,7 +568,7 @@ setgroups flock gettimeofday \ setsid chdir \ chsize ftruncate execve getpeereid basename dirname \ - epoll_create strsep \ + epoll_create strsep strtok_r \ ]) AC_CHECK_LIB(
src/compat/Makefile.am +2 -1
@@ -20,4 +20,5 @@ compat-basename.c \ compat-gettimeofday.c \ compat-daemon.c \ - compat-strsep.c + compat-strsep.c \ + compat-strtok_r.c
src/compat/compat-strtok_r.c new file +101 -0
102 lines not on this page · raw message
src/compat/compat.h +5 -0
@@ -61,4 +61,9 @@#endif +#ifndef HAVE_STRTOK_R +char * +strtok_r (char *s,const char *delim,char **last); +#endif +#endif /* COMPAT_H */
src/openvpn/options_util.c +3 -2
@@ -48,7 +48,8 @@ message =strstr (reason,"]" ) +1 ;/* null terminate the substring to only looks for flags between [ and ] */ *endofflags ='\x00' ; -const char *token =strtok (m,"[," ); +char *lasts =NULL ; +const char *token =strtok_r (m,"[," , &lasts);while (token) {if (!strncmp (token,"backoff " ,strlen ("backoff " )))
@@ -81,7 +82,7 @@ {msg (D_PUSH_ERRORS ,"WARNING: unknown AUTH_FAIL,TEMP flag: %s" , token); } - token =strtok (NULL ,"[," ); + token =strtok_r (NULL ,"[," , &lasts); } }
src/openvpn/ssl_mbedtls.c +3 -2
@@ -318,9 +318,10 @@/* Parse allowed ciphers, getting IDs */ int i =0 ; +char *lasts =NULL ; tmp_ciphers_orig = tmp_ciphers =string_alloc (ciphers,NULL ); - token =strtok (tmp_ciphers,":" ); + token =strtok_r (tmp_ciphers,":" , &lasts);while (token) { ctx->allowed_ciphers[i] =mbedtls_ssl_get_ciphersuite_id (tls_translate_cipher_name (token));
@@ -328,7 +329,7 @@ { i++; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig); }
src/openvpn/ssl_ncp.c +6 -4
@@ -100,7 +100,8 @@struct buffer new_list =alloc_buf (MAX_NCP_CIPHERS_LENGTH );char *const tmp_ciphers =string_alloc (list,NULL ); -const char *token =strtok (tmp_ciphers,":" ); +char *lasts =NULL ; +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {/*
@@ -174,7 +175,7 @@buf_puts (&new_list, ovpn_cipher_name); } } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }
@@ -207,15 +208,16 @@ {char *tmp_ciphers =string_alloc (list,NULL );char *tmp_ciphers_orig = tmp_ciphers; +char *lasts =NULL ; -const char *token =strtok (tmp_ciphers,":" ); +const char *token =strtok_r (tmp_ciphers,":" , &lasts);while (token) {if (0 ==strcmp (token, item)) {break ; } - token =strtok (NULL ,":" ); + token =strtok_r (NULL ,":" , &lasts); }free (tmp_ciphers_orig);
src/openvpn/ssl_verify.c +3 -2
@@ -868,7 +868,8 @@return false; } -const char *client_method =strtok (iv_sso,"," ); +char *lasts =NULL ; +const char *client_method =strtok_r (iv_sso,"," , &lasts);bool supported = false;while (client_method)
@@ -878,7 +879,7 @@ supported = true;break ; } - client_method =strtok (NULL ,"," ); + client_method =strtok_r (NULL ,"," , &lasts); }gc_free (&gc);
tests/unit_tests/openvpn/Makefile.am +2 -0
@@ -107,6 +107,7 @@ $(top_srcdir)/src/openvpn/base64.c \ $(top_srcdir)/src/openvpn/buffer.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/crypto.c \ $(top_srcdir)/src/openvpn/cryptoapi.c \ $(top_srcdir)/src/openvpn/crypto_epoch.c \
@@ -345,6 +346,7 @@ $(top_srcdir)/src/openvpn/platform.c \ $(top_srcdir)/src/openvpn/win32-util.c \ $(top_srcdir)/src/compat/compat-strsep.c \ + $(top_srcdir)/src/compat/compat-strtok_r.c \ $(top_srcdir)/src/openvpn/ssl_util.c mbuf_testdriver_CFLAGS = \
--
To view, visit http://gerrit.openvpn.net/c/openvpn/+/1679?usp=email
To unsubscribe, or for help writing mail filters, visit http://gerrit.openvpn.net/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: openvpn
Gerrit-Branch: master
Gerrit-Change-Id: I70560efd113308b7377424127eb2c1da4266371a
Gerrit-Change-Number: 1679
Gerrit-PatchSet: 6
Gerrit-Owner: plaisthos <[email protected]>
Gerrit-Reviewer: flichtenheld <[email protected]>
Gerrit-CC: openvpn-devel <[email protected]>
_______________________________________________
Openvpn-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/openvpn-devel