Convert all uses of strtok() in libraries to strtok_r() for thread
authorGreg Hudson <ghudson@mit.edu>
Mon, 10 Aug 2009 05:02:43 +0000 (05:02 +0000)
committerGreg Hudson <ghudson@mit.edu>
Mon, 10 Aug 2009 05:02:43 +0000 (05:02 +0000)
safety.

git-svn-id: svn://anonsvn.mit.edu/krb5/trunk@22513 dc483132-0cff-0310-8789-dd5450dbe970

src/lib/kadm5/srv/server_acl.c
src/plugins/preauth/pkinit/pkinit_identity.c

index fd245babe7dd8c7c6d8fdd0c252b5047f52f26c7..45f3879b89c9f1864ac38ae1baf8d8fab45fc7e3 100644 (file)
@@ -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;
                    }
index 4e9f61ef5e4e14e0166ce6e7f665016733979df5..fc4d08d710a4ba7206532e76474c76b24d110c54 100644 (file)
@@ -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)