From 505dc481d11ca0be3f4f99275c28cd3f5a3eed57 Mon Sep 17 00:00:00 2001 From: Greg Hudson Date: Mon, 10 Aug 2009 05:02:43 +0000 Subject: [PATCH] Convert all uses of strtok() in libraries to strtok_r() for thread safety. git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22513 dc483132-0cff-0310-8789-dd5450dbe970 --- src/lib/kadm5/srv/server_acl.c | 7 ++++--- src/plugins/preauth/pkinit/pkinit_identity.c | 10 +++++----- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/lib/kadm5/srv/server_acl.c b/src/lib/kadm5/srv/server_acl.c index fd245babe..45f3879b8 100644 --- a/src/lib/kadm5/srv/server_acl.c +++ b/src/lib/kadm5/srv/server_acl.c @@ -282,7 +282,7 @@ kadm5int_acl_parse_restrictions(s, rpp) char *s; restriction_t **rpp; { - char *sp = NULL, *tp, *ap; + char *sp = NULL, *tp, *ap, *save; static const char *delims = "\t\n\f\v\r ,"; krb5_deltat dt; krb5_flags flag; @@ -299,7 +299,8 @@ kadm5int_acl_parse_restrictions(s, rpp) code = ENOMEM; } else { memset(*rpp, 0, sizeof(**rpp)); - for (tp=strtok(sp, delims); tp; tp=strtok((char *)NULL, delims)) { + for (tp = strtok_r(sp, delims, &save); tp; + tp = strtok_r(NULL, delims, &save)) { flag = 0; if (!krb5_string_to_flags(tp, "+", "-", &flag)) { /* OK, but was it in the positive or negative sense? */ @@ -315,7 +316,7 @@ kadm5int_acl_parse_restrictions(s, rpp) (*rpp)->mask |= KADM5_POLICY_CLR; } else { /* everything else needs an argument ... */ - if (!(ap = strtok((char *)NULL, delims))) { + if (!(ap = strtok_r(NULL, delims, &save))) { code = EINVAL; break; } diff --git a/src/plugins/preauth/pkinit/pkinit_identity.c b/src/plugins/preauth/pkinit/pkinit_identity.c index 4e9f61ef5..fc4d08d71 100644 --- a/src/plugins/preauth/pkinit/pkinit_identity.c +++ b/src/plugins/preauth/pkinit/pkinit_identity.c @@ -261,7 +261,7 @@ parse_pkcs11_options(krb5_context context, pkinit_identity_opts *idopts, const char *residual) { - char *s, *cp, *vp; + char *s, *cp, *vp, *save; krb5_error_code retval = ENOMEM; if (residual == NULL || residual[0] == '\0') @@ -272,7 +272,7 @@ parse_pkcs11_options(krb5_context context, if (s == NULL) return retval; - for ((cp = strtok(s, ":")); cp; (cp = strtok(NULL, ":"))) { + for (cp = strtok_r(s, ":", &save); cp; cp = strtok_r(NULL, ":", &save)) { vp = strchr(cp, '='); /* If there is no "=", this is a pkcs11 module name */ @@ -334,7 +334,7 @@ parse_fs_options(krb5_context context, pkinit_identity_opts *idopts, const char *residual) { - char *certname, *keyname; + char *certname, *keyname, *save; krb5_error_code retval = ENOMEM; if (residual == NULL || residual[0] == '\0') @@ -344,8 +344,8 @@ parse_fs_options(krb5_context context, if (certname == NULL) goto cleanup; - certname = strtok(certname, ","); - keyname = strtok(NULL, ","); + certname = strtok_r(certname, ",", &save); + keyname = strtok_r(NULL, ",", &save); idopts->cert_filename = strdup(certname); if (idopts->cert_filename == NULL) -- 2.26.2