MFB: Fixed bug #39623 (thread safety fixes on *nix for mime_magic extenion).

This commit is contained in:
Ilia Alshanetsky 2006-11-26 17:03:15 +00:00
parent 1c4d86e6d4
commit 41da75d59f

View file

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