]> granicus.if.org Git - php/commitdiff
MFB: Fixed bug #39623 (thread safety fixes on *nix for mime_magic extenion).
authorIlia Alshanetsky <iliaa@php.net>
Sun, 26 Nov 2006 17:03:15 +0000 (17:03 +0000)
committerIlia Alshanetsky <iliaa@php.net>
Sun, 26 Nov 2006 17:03:15 +0000 (17:03 +0000)
ext/mime_magic/mime_magic.c

index 958501cc24708ce996bba71470bd8a1f55f6e63b..3bd1b217969eea1b151d80b6fd61aa16c74c2f98 100644 (file)
@@ -1388,6 +1388,7 @@ static int ascmagic(unsigned char *buf, int nbytes)
     char *token;
     register struct names *p;
     int small_nbytes;
+    char *strtok_buf = NULL;
 
     /* these are easy, do them first */
 
@@ -1420,8 +1421,7 @@ static int ascmagic(unsigned char *buf, int nbytes)
     s = (unsigned char *) memcpy(nbuf, buf, small_nbytes);
     s[small_nbytes] = '\0';
     has_escapes = (memchr(s, '\033', small_nbytes) != NULL);
-    /* XXX: not multithread safe */
-    while ((token = strtok((char *) s, " \t\n\r\f")) != NULL) {
+    while ((token = php_strtok_r((char *) s, " \t\n\r\f", &strtok_buf)) != NULL) {
                s = NULL;               /* make strtok() keep on tokin' */
                for (p = names; p < names + NNAMES; p++) {
                        if (STREQ(p->name, token)) {