pajoye                                   Tue, 08 Jun 2010 22:30:16 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=300296

Log:
- [DOC] MFH: add session.entropy* support to windows

Changed paths:
    U   php/php-src/branches/PHP_5_3/ext/session/session.c
    U   php/php-src/trunk/ext/session/session.c

Modified: php/php-src/branches/PHP_5_3/ext/session/session.c
===================================================================
--- php/php-src/branches/PHP_5_3/ext/session/session.c  2010-06-08 22:27:14 UTC 
(rev 300295)
+++ php/php-src/branches/PHP_5_3/ext/session/session.c  2010-06-08 22:30:16 UTC 
(rev 300296)
@@ -26,7 +26,8 @@
 #include "php.h"

 #ifdef PHP_WIN32
-#include "win32/time.h"
+# include "win32/winutil.h"
+# include "win32/time.h"
 #else
 #include <sys/time.h>
 #endif
@@ -402,6 +403,28 @@
        efree(buf);

        if (PS(entropy_length) > 0) {
+               unsigned char rbuf[2048];
+
+#ifdef PHP_WIN32
+               size_t toread = PS(entropy_length);
+
+               if (php_win32_get_random_bytes(rbuf, (size_t) toread) == 
SUCCESS){
+
+                       switch (PS(hash_func)) {
+                               case PS_HASH_FUNC_MD5:
+                                       PHP_MD5Update(&md5_context, rbuf, 
toread);
+                                       break;
+                               case PS_HASH_FUNC_SHA1:
+                                       PHP_SHA1Update(&sha1_context, rbuf, 
toread);
+                                       break;
+# if defined(HAVE_HASH_EXT) && !defined(COMPILE_DL_HASH)
+                               case PS_HASH_FUNC_OTHER:
+                                       PS(hash_ops)->hash_update(hash_context, 
rbuf, toread);
+                                       break;
+# endif /* HAVE_HASH_EXT */
+                       }
+               }
+#else
                int fd;

                fd = VCWD_OPEN(PS(entropy_file), O_RDONLY);
@@ -431,6 +454,7 @@
                        }
                        close(fd);
                }
+#endif
        }

        digest = emalloc(digest_len + 1);

Modified: php/php-src/trunk/ext/session/session.c
===================================================================
--- php/php-src/trunk/ext/session/session.c     2010-06-08 22:27:14 UTC (rev 
300295)
+++ php/php-src/trunk/ext/session/session.c     2010-06-08 22:30:16 UTC (rev 
300296)
@@ -333,7 +333,7 @@

 #ifdef PHP_WIN32
                size_t toread = PS(entropy_length);
-               __debugbreak();
+
                if (php_win32_get_random_bytes(rbuf, (size_t) toread) == 
SUCCESS){

                        switch (PS(hash_func)) {

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

Reply via email to