[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mime_magic mime_magic.c

2007-02-14 Thread Ilia Alshanetsky
iliaa   Thu Feb 15 00:05:42 2007 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/mime_magic mime_magic.c 
  Log:
  Fixed a possible memory corruption inside mime_content_type() on a
  non-existent file.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mime_magic/mime_magic.c?r1=1.42.2.5.2.5r2=1.42.2.5.2.6diff_format=u
Index: php-src/ext/mime_magic/mime_magic.c
diff -u php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.5 
php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.6
--- php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.5Mon Jan  1 09:36:03 2007
+++ php-src/ext/mime_magic/mime_magic.c Thu Feb 15 00:05:42 2007
@@ -15,7 +15,7 @@
   | Author: Hartmut Holzgraefe  [EMAIL PROTECTED]   |
   +--+
 
-  $Id: mime_magic.c,v 1.42.2.5.2.5 2007/01/01 09:36:03 sebastian Exp $ 
+  $Id: mime_magic.c,v 1.42.2.5.2.6 2007/02/15 00:05:42 iliaa Exp $ 
 
   This module contains a lot of stuff taken from Apache mod_mime_magic,
   so the license section is a little bit longer than usual:
@@ -1156,21 +1156,29 @@
php_stream_statbuf stat_ssb;
 
switch (Z_TYPE_P(what)) {
-   case IS_STRING:
-   if(!php_stream_stat_path(Z_STRVAL_P(what), stat_ssb)) {
-   return MIME_MAGIC_OK;
-   }
-   break;
-   case IS_RESOURCE:
-   {
-   php_stream *stream;
-
-   php_stream_from_zval_no_verify(stream, what);
-   if(!php_stream_stat(stream, stat_ssb)) {
-   return MIME_MAGIC_OK;
+   case IS_STRING:
+   if (php_stream_stat_path_ex(Z_STRVAL_P(what), 
PHP_STREAM_URL_STAT_QUIET, stat_ssb, NULL)) {
+   if (MIME_MAGIC_G(debug)) {
+   php_error_docref(NULL TSRMLS_CC, 
E_WARNING, Non-statable file path (%s), Z_STRVAL_P(what));
+   }
+   return MIME_MAGIC_ERROR;
}
-   }
-   break;
+   break;
+   case IS_RESOURCE:
+   {
+   php_stream *stream;
+   
+   php_stream_from_zval_no_verify(stream, what);
+   if (php_stream_stat(stream, stat_ssb)) {
+   if (MIME_MAGIC_G(debug)) {
+   php_error_docref(NULL 
TSRMLS_CC, E_WARNING, Non-statable file path (%s), Z_STRVAL_P(what));
+   }
+   return MIME_MAGIC_ERROR;
+   }
+   }
+   break;
+   default:
+   return MIME_MAGIC_OK;
}
 
 switch (stat_ssb.sb.st_mode  S_IFMT) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mime_magic mime_magic.c

2006-12-28 Thread Antony Dovgal
tony2001Thu Dec 28 20:45:27 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/mime_magic mime_magic.c 
  Log:
  MFH
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mime_magic/mime_magic.c?r1=1.42.2.5.2.3r2=1.42.2.5.2.4diff_format=u
Index: php-src/ext/mime_magic/mime_magic.c
diff -u php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.3 
php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.4
--- php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.3Thu Nov 30 15:13:19 2006
+++ php-src/ext/mime_magic/mime_magic.c Thu Dec 28 20:45:27 2006
@@ -15,7 +15,7 @@
   | Author: Hartmut Holzgraefe  [EMAIL PROTECTED]   |
   +--+
 
-  $Id: mime_magic.c,v 1.42.2.5.2.3 2006/11/30 15:13:19 iliaa Exp $ 
+  $Id: mime_magic.c,v 1.42.2.5.2.4 2006/12/28 20:45:27 tony2001 Exp $ 
 
   This module contains a lot of stuff taken from Apache mod_mime_magic,
   so the license section is a little bit longer than usual:
@@ -730,9 +730,7 @@
return -1;
}

-   strncpy(m-desc, l, sizeof(m-desc) - 1);
-   m-desc[sizeof(m-desc) - 1] = '\0';
-
+   strlcpy(m-desc, l, sizeof(m-desc));
 return 0;
 }
 

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mime_magic mime_magic.c

2006-11-30 Thread Ilia Alshanetsky
iliaa   Thu Nov 30 15:13:20 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/mime_magic mime_magic.c 
  Log:
  Use thread-safe code
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mime_magic/mime_magic.c?r1=1.42.2.5.2.2r2=1.42.2.5.2.3diff_format=u
Index: php-src/ext/mime_magic/mime_magic.c
diff -u php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.2 
php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.3
--- php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.2Sun Nov 26 17:02:13 2006
+++ php-src/ext/mime_magic/mime_magic.c Thu Nov 30 15:13:19 2006
@@ -15,7 +15,7 @@
   | Author: Hartmut Holzgraefe  [EMAIL PROTECTED]   |
   +--+
 
-  $Id: mime_magic.c,v 1.42.2.5.2.2 2006/11/26 17:02:13 iliaa Exp $ 
+  $Id: mime_magic.c,v 1.42.2.5.2.3 2006/11/30 15:13:19 iliaa Exp $ 
 
   This module contains a lot of stuff taken from Apache mod_mime_magic,
   so the license section is a little bit longer than usual:
@@ -1755,12 +1755,15 @@
 case DATE:
 case BEDATE:
 case LEDATE:
-   /* XXX: not multithread safe */
-   pp = ctime((time_t *)  p-l);
-   if ((rt = strchr(pp, '\n')) != NULL)
-   *rt = '\0';
-   (void) magic_rsl_printf(m-desc, pp);
-   return;
+   {
+   char ctimebuf[52];
+   pp = php_ctime_r((time_t *) p-l, ctimebuf);
+   if ((rt = strchr(pp, '\n')) != NULL) {
+   *rt = '\0';
+   }
+   (void) magic_rsl_printf(m-desc, pp);
+   return;
+   }
 default:
{
TSRMLS_FETCH();

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php-src(PHP_5_2) /ext/mime_magic mime_magic.c /ext/standard basic_functions.c

2006-11-26 Thread Ilia Alshanetsky
iliaa   Sun Nov 26 17:02:13 2006 UTC

  Modified files:  (Branch: PHP_5_2)
/php-src/ext/mime_magic mime_magic.c 
/php-src/ext/standard   basic_functions.c 
  Log:
  Fixed bug #39623 (thread safety fixes on *nix for putenv()  mime_magic).
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/mime_magic/mime_magic.c?r1=1.42.2.5.2.1r2=1.42.2.5.2.2diff_format=u
Index: php-src/ext/mime_magic/mime_magic.c
diff -u php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.1 
php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.2
--- php-src/ext/mime_magic/mime_magic.c:1.42.2.5.2.1Thu Jun 15 18:33:07 2006
+++ php-src/ext/mime_magic/mime_magic.c Sun Nov 26 17:02:13 2006
@@ -15,7 +15,7 @@
   | Author: Hartmut Holzgraefe  [EMAIL PROTECTED]   |
   +--+
 
-  $Id: mime_magic.c,v 1.42.2.5.2.1 2006/06/15 18:33:07 dmitry Exp $ 
+  $Id: mime_magic.c,v 1.42.2.5.2.2 2006/11/26 17:02:13 iliaa Exp $ 
 
   This module contains a lot of stuff taken from Apache mod_mime_magic,
   so the license section is a little bit longer than usual:
@@ -1388,6 +1388,7 @@
 char *token;
 register struct names *p;
 int small_nbytes;
+char *strtok_buf = NULL;
 
 /* these are easy, do them first */
 
@@ -1420,8 +1421,7 @@
 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)) {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.c?r1=1.725.2.31.2.30r2=1.725.2.31.2.31diff_format=u
Index: php-src/ext/standard/basic_functions.c
diff -u php-src/ext/standard/basic_functions.c:1.725.2.31.2.30 
php-src/ext/standard/basic_functions.c:1.725.2.31.2.31
--- php-src/ext/standard/basic_functions.c:1.725.2.31.2.30  Fri Nov 10 
11:42:07 2006
+++ php-src/ext/standard/basic_functions.c  Sun Nov 26 17:02:13 2006
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.725.2.31.2.30 2006/11/10 11:42:07 dmitry Exp $ */
+/* $Id: basic_functions.c,v 1.725.2.31.2.31 2006/11/26 17:02:13 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -4398,7 +4398,8 @@
/* Check the allowed list */
if (BG(sm_allowed_env_vars)  
*BG(sm_allowed_env_vars)) {
char *allowed_env_vars = 
estrdup(BG(sm_allowed_env_vars));
-   char *allowed_prefix = strtok(allowed_env_vars, 
, );
+   char *strtok_buf = NULL;
+   char *allowed_prefix = 
php_strtok_r(allowed_env_vars, , , strtok_buf);
zend_bool allowed = 0;
 
while (allowed_prefix) {
@@ -4406,7 +4407,7 @@
allowed = 1;
break;
}
-   allowed_prefix = strtok(NULL, , );
+   allowed_prefix = php_strtok_r(NULL, , 
, strtok_buf);
}
efree(allowed_env_vars);
if (!allowed) {

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php