From: Ilia Alshanetsky Date: Sun, 26 Nov 2006 17:03:15 +0000 (+0000) Subject: MFB: Fixed bug #39623 (thread safety fixes on *nix for mime_magic extenion). X-Git-Tag: RELEASE_1_0_0RC1~904 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=41da75d59f79875596bca8827c1331efa6131a76;p=php MFB: Fixed bug #39623 (thread safety fixes on *nix for mime_magic extenion). --- diff --git a/ext/mime_magic/mime_magic.c b/ext/mime_magic/mime_magic.c index 958501cc24..3bd1b21796 100644 --- a/ext/mime_magic/mime_magic.c +++ b/ext/mime_magic/mime_magic.c @@ -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)) {