diff options
| author | Jani Taskinen <jani@php.net> | 2008-08-25 13:42:55 +0000 |
|---|---|---|
| committer | Jani Taskinen <jani@php.net> | 2008-08-25 13:42:55 +0000 |
| commit | 505ad55773f514a8ddc228212850f3be95a05a82 (patch) | |
| tree | 3da94be6766ccaa6c797abb71101660ac197142a /ext/standard | |
| parent | f1e4ae0867f1481706919c87355a3bf48b565290 (diff) | |
| download | php-git-505ad55773f514a8ddc228212850f3be95a05a82.tar.gz | |
MFH
Diffstat (limited to 'ext/standard')
| -rw-r--r-- | ext/standard/config.m4 | 19 | ||||
| -rw-r--r-- | ext/standard/crypt_freesec.c | 86 | ||||
| -rw-r--r-- | ext/standard/crypt_freesec.h | 27 | ||||
| -rw-r--r-- | ext/standard/tests/general_functions/bug41518.phpt | 8 |
4 files changed, 54 insertions, 86 deletions
diff --git a/ext/standard/config.m4 b/ext/standard/config.m4 index 79839bebc8..125e7266a3 100644 --- a/ext/standard/config.m4 +++ b/ext/standard/config.m4 @@ -464,25 +464,6 @@ if test "$ac_cv_type_mbstate_t" = "yes"; then fi dnl -dnl Check for u_int32_t -dnl -AC_CACHE_CHECK([for u_int32_t], [ac_cv_type_u_int32_t],[ -AC_TRY_COMPILE([ -#ifdef HAVE_SYS_TYPES_H -# include <sys/types.h> -#endif -],[ -int __tmp__() { u_int32_t a; } -],[ - ac_cv_type_u_int32_t=yes -],[ - ac_cv_type_u_int32_t=no -])]) -if test "$ac_cv_type_u_int32_t" = "yes"; then - AC_DEFINE([HAVE_U_INT32_T], 1, [Define if your system has u_int32_t in sys/types.h]) -fi - -dnl dnl Setup extension sources dnl PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c crypt.c \ diff --git a/ext/standard/crypt_freesec.c b/ext/standard/crypt_freesec.c index b408a85f31..7ed277092d 100644 --- a/ext/standard/crypt_freesec.c +++ b/ext/standard/crypt_freesec.c @@ -65,24 +65,6 @@ #include <sys/types.h> #include <string.h> -#ifdef TEST -#include <stdio.h> -#endif - - -#if defined(__GNUC__) -# ifdef inline -# undef inline -# endif -# define inline inline __attribute__((always_inline)) -#elif defined(_MSC_VER) -# define inline __forceinline -#else -# ifndef inline -# define inline -# endif -#endif - #include "crypt_freesec.h" #define _PASSWORD_EFMT1 '_' @@ -172,7 +154,7 @@ static u_char pbox[32] = { 2, 8, 24, 14, 32, 27, 3, 9, 19, 13, 30, 6, 22, 11, 4, 25 }; -static u_int32_t bits32[32] = +static uint32_t bits32[32] = { 0x80000000, 0x40000000, 0x20000000, 0x10000000, 0x08000000, 0x04000000, 0x02000000, 0x01000000, @@ -192,11 +174,11 @@ static unsigned char ascii64[] = /* 0123456789012345678901234567890123456789012345678901234567890123 */ static u_char m_sbox[4][4096]; -static u_int32_t psbox[4][256]; -static u_int32_t ip_maskl[8][256], ip_maskr[8][256]; -static u_int32_t fp_maskl[8][256], fp_maskr[8][256]; -static u_int32_t key_perm_maskl[8][128], key_perm_maskr[8][128]; -static u_int32_t comp_maskl[8][128], comp_maskr[8][128]; +static uint32_t psbox[4][256]; +static uint32_t ip_maskl[8][256], ip_maskr[8][256]; +static uint32_t fp_maskl[8][256], fp_maskr[8][256]; +static uint32_t key_perm_maskl[8][128], key_perm_maskr[8][128]; +static uint32_t comp_maskl[8][128], comp_maskr[8][128]; static inline int ascii_to_bin(char ch) @@ -220,8 +202,8 @@ void _crypt_extended_init(void) { int i, j, b, k, inbit, obit; - u_int32_t *p, *il, *ir, *fl, *fr; - u_int32_t *bits28, *bits24; + uint32_t *p, *il, *ir, *fl, *fr; + uint32_t *bits28, *bits24; u_char inv_key_perm[64]; u_char u_key_perm[56]; u_char inv_comp_perm[56]; @@ -359,9 +341,9 @@ des_init_local(struct php_crypt_extended_data *data) } static void -setup_salt(u_int32_t salt, struct php_crypt_extended_data *data) +setup_salt(uint32_t salt, struct php_crypt_extended_data *data) { - u_int32_t obit, saltbit, saltbits; + uint32_t obit, saltbit, saltbits; int i; if (salt == data->old_salt) @@ -383,19 +365,19 @@ setup_salt(u_int32_t salt, struct php_crypt_extended_data *data) static int des_setkey(const char *key, struct php_crypt_extended_data *data) { - u_int32_t k0, k1, rawkey0, rawkey1; + uint32_t k0, k1, rawkey0, rawkey1; int shifts, round; rawkey0 = - (u_int32_t)(u_char)key[3] | - ((u_int32_t)(u_char)key[2] << 8) | - ((u_int32_t)(u_char)key[1] << 16) | - ((u_int32_t)(u_char)key[0] << 24); + (uint32_t)(u_char)key[3] | + ((uint32_t)(u_char)key[2] << 8) | + ((uint32_t)(u_char)key[1] << 16) | + ((uint32_t)(u_char)key[0] << 24); rawkey1 = - (u_int32_t)(u_char)key[7] | - ((u_int32_t)(u_char)key[6] << 8) | - ((u_int32_t)(u_char)key[5] << 16) | - ((u_int32_t)(u_char)key[4] << 24); + (uint32_t)(u_char)key[7] | + ((uint32_t)(u_char)key[6] << 8) | + ((uint32_t)(u_char)key[5] << 16) | + ((uint32_t)(u_char)key[4] << 24); if ((rawkey0 | rawkey1) && rawkey0 == data->old_rawkey0 @@ -435,7 +417,7 @@ des_setkey(const char *key, struct php_crypt_extended_data *data) */ shifts = 0; for (round = 0; round < 16; round++) { - u_int32_t t0, t1; + uint32_t t0, t1; shifts += key_shifts[round]; @@ -466,14 +448,14 @@ des_setkey(const char *key, struct php_crypt_extended_data *data) } static int -do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, +do_des(uint32_t l_in, uint32_t r_in, uint32_t *l_out, uint32_t *r_out, int count, struct php_crypt_extended_data *data) { /* * l_in, r_in, l_out, and r_out are in pseudo-"big-endian" format. */ - u_int32_t l, r, *kl, *kr, *kl1, *kr1; - u_int32_t f, r48l, r48r, saltbits; + uint32_t l, r, *kl, *kr, *kl1, *kr1; + uint32_t f, r48l, r48r, saltbits; int round; if (count == 0) { @@ -584,24 +566,24 @@ do_des(u_int32_t l_in, u_int32_t r_in, u_int32_t *l_out, u_int32_t *r_out, } static int -des_cipher(const char *in, char *out, u_int32_t salt, int count, +des_cipher(const char *in, char *out, uint32_t salt, int count, struct php_crypt_extended_data *data) { - u_int32_t l_out, r_out, rawl, rawr; + uint32_t l_out, r_out, rawl, rawr; int retval; setup_salt(salt, data); rawl = - (u_int32_t)(u_char)in[3] | - ((u_int32_t)(u_char)in[2] << 8) | - ((u_int32_t)(u_char)in[1] << 16) | - ((u_int32_t)(u_char)in[0] << 24); + (uint32_t)(u_char)in[3] | + ((uint32_t)(u_char)in[2] << 8) | + ((uint32_t)(u_char)in[1] << 16) | + ((uint32_t)(u_char)in[0] << 24); rawr = - (u_int32_t)(u_char)in[7] | - ((u_int32_t)(u_char)in[6] << 8) | - ((u_int32_t)(u_char)in[5] << 16) | - ((u_int32_t)(u_char)in[4] << 24); + (uint32_t)(u_char)in[7] | + ((uint32_t)(u_char)in[6] << 8) | + ((uint32_t)(u_char)in[5] << 16) | + ((uint32_t)(u_char)in[4] << 24); retval = do_des(rawl, rawr, &l_out, &r_out, count, data); @@ -622,7 +604,7 @@ _crypt_extended_r(const char *key, const char *setting, struct php_crypt_extended_data *data) { int i; - u_int32_t count, salt, l, r0, r1, keybuf[2]; + uint32_t count, salt, l, r0, r1, keybuf[2]; u_char *p, *q; if (!data->initialized) diff --git a/ext/standard/crypt_freesec.h b/ext/standard/crypt_freesec.h index 96ca7d020f..f4a63d1630 100644 --- a/ext/standard/crypt_freesec.h +++ b/ext/standard/crypt_freesec.h @@ -1,17 +1,24 @@ /* $Id$ */ + #ifndef _CRYPT_FREESEC_H #define _CRYPT_FREESEC_H +#include "php_config.h" #if PHP_WIN32 # include "win32/php_stdint.h" #else -# include "php_config.h" -# if HAVE_STDINT_H -# include <stdint.h> +# if HAVE_INTTYPES_H +# include <inttypes.h> +# elif HAVE_STDINT_H +# include <stdint.h> # endif -# ifndef HAVE_U_INT32_T - typedef uint32_t u_int32_t; +# ifndef HAVE_UINT32_T +# if SIZEOF_INT == 4 +typedef unsigned int uint32_t; +# elif SIZEOF_LONG == 4 +typedef unsigned long int uint32_t; +# endif # endif #endif @@ -19,11 +26,11 @@ struct php_crypt_extended_data { int initialized; - u_int32_t saltbits; - u_int32_t old_salt; - u_int32_t en_keysl[16], en_keysr[16]; - u_int32_t de_keysl[16], de_keysr[16]; - u_int32_t old_rawkey0, old_rawkey1; + uint32_t saltbits; + uint32_t old_salt; + uint32_t en_keysl[16], en_keysr[16]; + uint32_t de_keysl[16], de_keysr[16]; + uint32_t old_rawkey0, old_rawkey1; char output[21]; }; diff --git a/ext/standard/tests/general_functions/bug41518.phpt b/ext/standard/tests/general_functions/bug41518.phpt index ca9188bf64..4a3858b4ea 100644 --- a/ext/standard/tests/general_functions/bug41518.phpt +++ b/ext/standard/tests/general_functions/bug41518.phpt @@ -2,8 +2,7 @@ Bug #41518 (file_exists() warns of open_basedir restriction on non-existent file) --SKIPIF-- <?php -/* let's use /tmp here */ -$tmp_dir = __DIR__ . '/tmp'; +$tmp_dir = __DIR__ . '/bug41518'; mkdir($tmp_dir); if (!is_dir($tmp_dir)) { die("skip"); @@ -14,7 +13,7 @@ open_basedir=. --FILE-- <?php -$tmp_dir = __DIR__ . '/tmp'; +$tmp_dir = __DIR__ . "/bug41518/"; $tmp_file = $tmp_dir."/bug41418.tmp"; touch($tmp_file); @@ -23,10 +22,9 @@ var_dump(file_exists($tmp_file."nosuchfile")); //doesn't exist @unlink($tmp_file); @rmdir($tmp_dir); - echo "Done\n"; ?> ---EXPECTF-- +--EXPECT-- bool(true) bool(false) Done |
