httpd-cvs mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From traw...@apache.org
Subject cvs commit: httpd-2.0/modules/metadata mod_mime_magic.c
Date Thu, 07 Jun 2001 14:45:08 GMT
trawick     01/06/07 07:45:07

  Modified:    modules/metadata mod_mime_magic.c
  Log:
  fix a thread-safety bug by using apr_strtok() instead of strtok()
  
  Revision  Changes    Path
  1.44      +4 -4      httpd-2.0/modules/metadata/mod_mime_magic.c
  
  Index: mod_mime_magic.c
  ===================================================================
  RCS file: /home/cvs/httpd-2.0/modules/metadata/mod_mime_magic.c,v
  retrieving revision 1.43
  retrieving revision 1.44
  diff -u -r1.43 -r1.44
  --- mod_mime_magic.c	2001/03/19 16:07:59	1.43
  +++ mod_mime_magic.c	2001/06/07 14:45:03	1.44
  @@ -2005,6 +2005,7 @@
       char *token;
       register struct names *p;
       int small_nbytes;
  +    char *strtok_state;
   
       /* these are easy, do them first */
   
  @@ -2033,13 +2034,12 @@
       /* look for tokens from names.h - this is expensive!, so we'll limit
        * ourselves to only SMALL_HOWMANY bytes */
       small_nbytes = (nbytes > SMALL_HOWMANY) ? SMALL_HOWMANY : nbytes;
  -    /* make a copy of the buffer here because strtok() will destroy it */
  +    /* make a copy of the buffer here because apr_strtok() will destroy it */
       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) {
  -	s = NULL;		/* make strtok() keep on tokin' */
  +    while ((token = apr_strtok((char *) s, " \t\n\r\f", &strtok_state)) != NULL) {
  +	s = NULL;		/* make apr_strtok() keep on tokin' */
   	for (p = names; p < names + NNAMES; p++) {
   	    if (STREQ(p->name, token)) {
   		magic_rsl_puts(r, types[p->type]);
  
  
  

Mime
View raw message