[PHP-CVS] cvs: php-src /ext/standard base64.c /ext/standard/tests/url bug47174.phpt

2009-01-25 Thread Ilia Alshanetsky
iliaa   Sun Jan 25 18:27:58 2009 UTC

  Modified files:  
/php-src/ext/standard/tests/url bug47174.phpt 
/php-src/ext/standard   base64.c 
  Log:
  MFB: Improved fix for bug #47174 & added a test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/url/bug47174.phpt?r1=1.1&r2=1.2&diff_format=u
Index: php-src/ext/standard/tests/url/bug47174.phpt
diff -u /dev/null php-src/ext/standard/tests/url/bug47174.phpt:1.2
--- /dev/null   Sun Jan 25 18:27:58 2009
+++ php-src/ext/standard/tests/url/bug47174.phptSun Jan 25 18:27:56 2009
@@ -0,0 +1,18 @@
+--TEST--
+Bug #47174 (base64_decode() interprets pad char in mid string as terminator)
+--FILE--
+
+--EXPECT--
+Invalid Signature
+string(10) "Zm9v==YmFy"
+string(6) "foobar"
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.58&r2=1.59&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.58 php-src/ext/standard/base64.c:1.59
--- php-src/ext/standard/base64.c:1.58  Wed Jan 21 15:45:45 2009
+++ php-src/ext/standard/base64.c   Sun Jan 25 18:27:58 2009
@@ -15,7 +15,7 @@
| Author: Jim Winstead   |
+--+
  */
-/* $Id: base64.c,v 1.58 2009/01/21 15:45:45 iliaa Exp $ */
+/* $Id: base64.c,v 1.59 2009/01/25 18:27:58 iliaa Exp $ */
 
 #include 
 
@@ -156,7 +156,6 @@
efree(result);
return NULL;
}
-   i++;
continue;
}
 



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



[PHP-CVS] cvs: php-src /ext/standard base64.c

2009-01-21 Thread Ilia Alshanetsky
iliaa   Wed Jan 21 15:45:45 2009 UTC

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  MFB: Fixed bug #47174 (base64_decode() interprets pad char in mid string as
  terminator)
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.57&r2=1.58&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.57 php-src/ext/standard/base64.c:1.58
--- php-src/ext/standard/base64.c:1.57  Wed Dec 31 11:12:36 2008
+++ php-src/ext/standard/base64.c   Wed Jan 21 15:45:45 2009
@@ -15,7 +15,7 @@
| Author: Jim Winstead   |
+--+
  */
-/* $Id: base64.c,v 1.57 2008/12/31 11:12:36 sebastian Exp $ */
+/* $Id: base64.c,v 1.58 2009/01/21 15:45:45 iliaa Exp $ */
 
 #include 
 
@@ -151,7 +151,14 @@
 
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0' && length-- > 0) {
-   if (ch == base64_pad) break;
+   if (ch == base64_pad) {
+   if (*current != '=' && (i % 4) == 1) {
+   efree(result);
+   return NULL;
+   }
+   i++;
+   continue;
+   }
 
ch = base64_reverse_table[ch];
if ((!strict && ch < 0) || ch == -1) { /* a space or some other 
separator character, we simply skip over */



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



[PHP-CVS] cvs: php-src /ext/standard base64.c

2007-11-05 Thread Jani Taskinen
janiMon Nov  5 12:07:28 2007 UTC

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  - ws + cs + nuke a warning
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.53&r2=1.54&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.53 php-src/ext/standard/base64.c:1.54
--- php-src/ext/standard/base64.c:1.53  Sat Jul 21 01:23:37 2007
+++ php-src/ext/standard/base64.c   Mon Nov  5 12:07:28 2007
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.53 2007/07/21 01:23:37 jani Exp $ */
+/* $Id: base64.c,v 1.54 2007/11/05 12:07:28 jani Exp $ */
 
 #include 
 
@@ -23,13 +23,13 @@
 #include "base64.h"
 
 /* {{{ base64 tables */
-static const char base64_table[] =
-   { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
- 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
- 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
- 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
- '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
-   };
+static const char base64_table[] = {
+   'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M',
+   'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
+   'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
+   'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
+   '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/', '\0'
+};
 
 static const char base64_pad = '=';
 
@@ -146,9 +146,9 @@
int ch, i = 0, j = 0, k;
/* this sucks for threaded environments */
unsigned char *result;
-   
+
result = (unsigned char *)safe_emalloc(length, 1, 1);
-   
+
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0' && length-- > 0) {
if (ch == base64_pad) break;
@@ -233,7 +233,7 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|b", &str, 
&str_len, &strict) == FAILURE) {
return;
}
-   result = php_base64_decode_ex(str, str_len, &ret_length, strict);
+   result = php_base64_decode_ex((unsigned char*)str, str_len, 
&ret_length, strict);
if (result != NULL) {
RETVAL_STRINGL((char*)result, ret_length, 0);
} else {

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



[PHP-CVS] cvs: php-src /ext/standard base64.c basic_functions.h info.c

2007-07-20 Thread Jani Taskinen
janiSat Jul 21 01:23:37 2007 UTC

  Modified files:  
/php-src/ext/standard   base64.c basic_functions.h info.c 
  Log:
  - Fix compile warnings
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.52&r2=1.53&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.52 php-src/ext/standard/base64.c:1.53
--- php-src/ext/standard/base64.c:1.52  Tue Jun 26 21:37:14 2007
+++ php-src/ext/standard/base64.c   Sat Jul 21 01:23:37 2007
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.52 2007/06/26 21:37:14 tony2001 Exp $ */
+/* $Id: base64.c,v 1.53 2007/07/21 01:23:37 jani Exp $ */
 
 #include 
 
@@ -104,7 +104,7 @@
 /* generate reverse table (do not set index 0 to 64)
 static unsigned short base64_reverse_table[256];
 #define rt base64_reverse_table
-void php_base64_init()
+void php_base64_init(void)
 {
char *s = emalloc(10240), *sp;
char *chp;
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/basic_functions.h?r1=1.155&r2=1.156&diff_format=u
Index: php-src/ext/standard/basic_functions.h
diff -u php-src/ext/standard/basic_functions.h:1.155 
php-src/ext/standard/basic_functions.h:1.156
--- php-src/ext/standard/basic_functions.h:1.155Mon May 28 12:18:26 2007
+++ php-src/ext/standard/basic_functions.h  Sat Jul 21 01:23:37 2007
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: basic_functions.h,v 1.155 2007/05/28 12:18:26 bjori Exp $ */
+/* $Id: basic_functions.h,v 1.156 2007/07/21 01:23:37 jani Exp $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -137,7 +137,7 @@
 PHP_RSHUTDOWN_FUNCTION(user_filters);
 
 PHPAPI int _php_error_log(int opt_err, char *message, char *opt, char *headers 
TSRMLS_DC);
-PHPAPI char *php_get_current_user();
+PHPAPI char *php_get_current_user(void);
 PHPAPI int php_prefix_varname(zval *result, zval *prefix, zstr var_name, int 
var_name_len, int var_name_type, zend_bool add_underscore TSRMLS_DC);
 
 #if SIZEOF_INT == 4
@@ -244,7 +244,7 @@
 #define SAFE_MODE_PROTECTED_ENV_VARS   "LD_LIBRARY_PATH"
 #define SAFE_MODE_ALLOWED_ENV_VARS "PHP_"
 
-PHPAPI double php_get_nan();
-PHPAPI double php_get_inf();
+PHPAPI double php_get_nan(void);
+PHPAPI double php_get_inf(void);
 
 #endif /* BASIC_FUNCTIONS_H */
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/info.c?r1=1.281&r2=1.282&diff_format=u
Index: php-src/ext/standard/info.c
diff -u php-src/ext/standard/info.c:1.281 php-src/ext/standard/info.c:1.282
--- php-src/ext/standard/info.c:1.281   Sat Jul 14 08:38:19 2007
+++ php-src/ext/standard/info.c Sat Jul 21 01:23:37 2007
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: info.c,v 1.281 2007/07/14 08:38:19 tony2001 Exp $ */
+/* $Id: info.c,v 1.282 2007/07/21 01:23:37 jani Exp $ */
 
 #include "php.h"
 #include "php_ini.h"
@@ -728,7 +728,7 @@
 }
 /* }}} */
 
-PHPAPI void php_info_print_table_start() /* {{{ */
+PHPAPI void php_info_print_table_start(void) /* {{{ */
 {
if (!sapi_module.phpinfo_as_text) {
php_info_print("\n");
@@ -738,7 +738,7 @@
 }
 /* }}} */
 
-PHPAPI void php_info_print_table_end() /* {{{ */
+PHPAPI void php_info_print_table_end(void) /* {{{ */
 {
if (!sapi_module.phpinfo_as_text) {
php_info_print("\n");
@@ -764,7 +764,7 @@
 }
 /* }}} */
 
-PHPAPI void php_info_print_box_end() /* {{{ */
+PHPAPI void php_info_print_box_end(void) /* {{{ */
 {
if (!sapi_module.phpinfo_as_text) {
php_info_print("\n");
@@ -773,7 +773,7 @@
 }
 /* }}} */
 
-PHPAPI void php_info_print_hr() /* {{{ */
+PHPAPI void php_info_print_hr(void) /* {{{ */
 {
if (!sapi_module.phpinfo_as_text) {
php_info_print("\n");
@@ -999,7 +999,7 @@
 
 /* {{{ php_logo_guid
  */
-PHPAPI char *php_logo_guid()
+PHPAPI char *php_logo_guid(void)
 {
char *logo_guid;
 

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



[PHP-CVS] cvs: php-src /ext/standard base64.c url.c

2006-10-26 Thread Andrei Zmievski
andrei  Thu Oct 26 17:33:33 2006 UTC

  Modified files:  
/php-src/ext/standard   base64.c url.c 
  Log:
  Make url encoding/decoding functions use binary strings only.
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.49&r2=1.50&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.49 php-src/ext/standard/base64.c:1.50
--- php-src/ext/standard/base64.c:1.49  Mon Sep 25 01:27:11 2006
+++ php-src/ext/standard/base64.c   Thu Oct 26 17:33:33 2006
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.49 2006/09/25 01:27:11 pollita Exp $ */
+/* $Id: base64.c,v 1.50 2006/10/26 17:33:33 andrei Exp $ */
 
 #include 
 
@@ -203,7 +203,7 @@
 }
 /* }}} */
 
-/* {{{ proto string base64_encode(string str) U
+/* {{{ proto binary base64_encode(binary str) U
Encodes string using MIME base64 algorithm */
 PHP_FUNCTION(base64_encode)
 {
@@ -224,7 +224,7 @@
 /* }}} */
 
 
-/* {{{ proto string base64_decode(string str[, bool strict]) U
+/* {{{ proto binary base64_decode(binary str[, bool strict]) U
Decodes string using MIME base64 algorithm */
 PHP_FUNCTION(base64_decode)
 {
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/url.c?r1=1.100&r2=1.101&diff_format=u
Index: php-src/ext/standard/url.c
diff -u php-src/ext/standard/url.c:1.100 php-src/ext/standard/url.c:1.101
--- php-src/ext/standard/url.c:1.100Sun Oct  8 13:34:24 2006
+++ php-src/ext/standard/url.c  Thu Oct 26 17:33:33 2006
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: url.c,v 1.100 2006/10/08 13:34:24 bjori Exp $ */
+/* $Id: url.c,v 1.101 2006/10/26 17:33:33 andrei Exp $ */
 
 #include 
 #include 
@@ -488,14 +488,14 @@
 }
 /* }}} */
 
-/* {{{ proto string urlencode(string str)
+/* {{{ proto string urlencode(binary str) U
URL-encodes string */
 PHP_FUNCTION(urlencode)
 {
char *in_str, *out_str;
int in_str_len, out_str_len;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &in_str,
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &in_str,
  &in_str_len) == 
FAILURE) {
return;
}
@@ -505,7 +505,7 @@
 }
 /* }}} */
 
-/* {{{ proto string urldecode(string str)
+/* {{{ proto binary urldecode(binary str) U
Decodes URL-encoded string */
 PHP_FUNCTION(urldecode)
 {
@@ -589,7 +589,7 @@
 }
 /* }}} */
 
-/* {{{ proto string rawurlencode(string str)
+/* {{{ proto binary rawurlencode(binary str) U
URL-encodes string */
 PHP_FUNCTION(rawurlencode)
 {
@@ -606,7 +606,7 @@
 }
 /* }}} */
 
-/* {{{ proto string rawurldecode(string str)
+/* {{{ proto binary rawurldecode(binary str) U
Decodes URL-encodes string */
 PHP_FUNCTION(rawurldecode)
 {

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



[PHP-CVS] cvs: php-src /ext/standard base64.c

2006-09-24 Thread Sara Golemon
pollita Mon Sep 25 01:27:11 2006 UTC

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  base64 functions are basicly binary-only ops
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.48&r2=1.49&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.48 php-src/ext/standard/base64.c:1.49
--- php-src/ext/standard/base64.c:1.48  Mon Jun 26 22:17:42 2006
+++ php-src/ext/standard/base64.c   Mon Sep 25 01:27:11 2006
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.48 2006/06/26 22:17:42 bjori Exp $ */
+/* $Id: base64.c,v 1.49 2006/09/25 01:27:11 pollita Exp $ */
 
 #include 
 
@@ -203,7 +203,7 @@
 }
 /* }}} */
 
-/* {{{ proto string base64_encode(string str)
+/* {{{ proto string base64_encode(string str) U
Encodes string using MIME base64 algorithm */
 PHP_FUNCTION(base64_encode)
 {
@@ -211,7 +211,7 @@
unsigned char *result;
int str_len, ret_length;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, 
&str_len) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "S", &str, 
&str_len) == FAILURE) {
return;
}
result = php_base64_encode((unsigned char*)str, str_len, &ret_length);
@@ -224,7 +224,7 @@
 /* }}} */
 
 
-/* {{{ proto string base64_decode(string str[, bool strict])
+/* {{{ proto string base64_decode(string str[, bool strict]) U
Decodes string using MIME base64 algorithm */
 PHP_FUNCTION(base64_decode)
 {

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



[PHP-CVS] cvs: php-src /ext/standard base64.c base64.h /ext/standard/tests/strings bug37244.phpt

2006-06-26 Thread Hannes Magnusson
bjori   Mon Jun 26 22:17:43 2006 UTC

  Added files: 
/php-src/ext/standard/tests/strings bug37244.phpt 

  Modified files:  
/php-src/ext/standard   base64.c base64.h 
  Log:
  MFB: bug #37244 (base64_decode violates RFC 3548)
  -Add test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.47&r2=1.48&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.47 php-src/ext/standard/base64.c:1.48
--- php-src/ext/standard/base64.c:1.47  Sun May 21 13:25:16 2006
+++ php-src/ext/standard/base64.c   Mon Jun 26 22:17:42 2006
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.47 2006/05/21 13:25:16 helly Exp $ */
+/* $Id: base64.c,v 1.48 2006/06/26 22:17:42 bjori Exp $ */
 
 #include 
 
@@ -34,22 +34,22 @@
 static const char base64_pad = '=';
 
 static const short base64_reverse_table[256] = {
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, -1, -1, 63,
-   52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1,
-   -1,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
-   15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-   -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-   41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -1, -1, -2, -2, -1, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -1, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, 62, -2, -2, -2, 63,
+   52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -2, -2, -2, -2, -2, -2,
+   -2,  0,  1,  2,  3,  4,  5,  6,  7,  8,  9, 10, 11, 12, 13, 14,
+   15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -2, -2, -2, -2, -2,
+   -2, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+   41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2,
+   -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2, -2
 };
 /* }}} */
 
@@ -135,9 +135,14 @@
 */
 /* }}} */
 
+PHPAPI unsigned char *php_base64_decode(const unsigned char *str, int length, 
int *ret_length)
+{
+   return php_base64_decode_ex(str, length, ret_length, 0);
+}
+
 /* {{{ php_base64_decode */
 /* as above, but backwards. :) */
-PHPAPI unsigned char *php_base64_decode(const unsigned char *str, int length, 
int *ret_length)
+PHPAPI unsigned char *php_base64_decode_ex(const unsigned char *str, int 
length, int *ret_length, zend_bool strict)
 {
const unsigned char *current = str;
int ch, i = 0, j = 0, k;
@@ -145,13 +150,18 @@
unsigned char *result;

result = (unsigned char *)safe_emalloc(length, 1, 1);
-
+   
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0' && length-- > 0) {
if (ch == base64_pad) break;
 
ch = base64_reverse_table[ch];
-   if (ch < 0) continue;
+   if ((!strict && ch < 0) || ch == -1) { /* a space or some other 
separator character, we simply skip over */
+   continue;
+   } else if (ch == -2) {
+   efree(result);
+   return NULL;
+   }
 
switch(i % 4) {
case 0:
@@ -214,18 +224,19 @@
 /* }}} */
 
 
-/* {{{ proto string base64_decode(string str)
+/* {{{ proto string base64_decode(string str[, bool strict])
Decodes string using MIME base64 algorithm */
 PHP_FUNCTION(base64_decode)
 {
char *str;
unsigned char *result;
+   zend_bool strict = 0;

[PHP-CVS] cvs: php-src /ext/standard base64.c

2006-05-21 Thread Marcus Boerger
helly   Sun May 21 13:25:16 2006 UTC

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  - Drop unneccesary check and change to safe_emalloc
  
http://cvs.php.net/viewcvs.cgi/php-src/ext/standard/base64.c?r1=1.46&r2=1.47&diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.46 php-src/ext/standard/base64.c:1.47
--- php-src/ext/standard/base64.c:1.46  Thu Mar  2 13:12:45 2006
+++ php-src/ext/standard/base64.c   Sun May 21 13:25:16 2006
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.46 2006/03/02 13:12:45 dmitry Exp $ */
+/* $Id: base64.c,v 1.47 2006/05/21 13:25:16 helly Exp $ */
 
 #include 
 
@@ -144,10 +144,7 @@
/* this sucks for threaded environments */
unsigned char *result;

-   result = (unsigned char *)emalloc(length + 1);
-   if (result == NULL) {
-   return NULL;
-   }
+   result = (unsigned char *)safe_emalloc(length, 1, 1);
 
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0' && length-- > 0) {

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



[PHP-CVS] cvs: php-src /ext/standard base64.c

2005-08-25 Thread Ilia Alshanetsky
iliaa   Thu Aug 25 23:32:53 2005 EDT

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  MFH: Fixed bug #34214 (base64_decode() does not properly ignore whitespace)
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/base64.c?r1=1.43&r2=1.44&ty=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.43 php-src/ext/standard/base64.c:1.44
--- php-src/ext/standard/base64.c:1.43  Wed Aug  3 10:07:56 2005
+++ php-src/ext/standard/base64.c   Thu Aug 25 23:32:53 2005
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  
|
+--+
  */
-/* $Id: base64.c,v 1.43 2005/08/03 14:07:56 sniper Exp $ */
+/* $Id: base64.c,v 1.44 2005/08/26 03:32:53 iliaa Exp $ */
 
 #include 
 
@@ -153,15 +153,6 @@
while ((ch = *current++) != '\0' && length-- > 0) {
if (ch == base64_pad) break;
 
-   /* When Base64 gets POSTed, all pluses are interpreted as spaces.
-  This line changes them back.  It's not exactly the Base64 
spec,
-  but it is completely compatible with it (the spec says that
-  spaces are invalid).  This will also save many people 
considerable
-  headache.  - Turadg Aleahmad <[EMAIL PROTECTED]>
-   */
-
-   if (ch == ' ') ch = '+'; 
-
ch = base64_reverse_table[ch];
if (ch < 0) continue;
 

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



[PHP-CVS] cvs: php-src /ext/standard base64.c

2004-03-06 Thread Ilia Alshanetsky
iliaa   Sat Mar  6 14:06:04 2004 EDT

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  Fixed bug #27460 (base64_decode() does not handle extra padding).
  
  
http://cvs.php.net/diff.php/php-src/ext/standard/base64.c?r1=1.41&r2=1.42&ty=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.41 php-src/ext/standard/base64.c:1.42
--- php-src/ext/standard/base64.c:1.41  Thu Jan  8 03:17:30 2004
+++ php-src/ext/standard/base64.c   Sat Mar  6 14:06:04 2004
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  |
+--+
  */
-/* $Id: base64.c,v 1.41 2004/01/08 08:17:30 andi Exp $ */
+/* $Id: base64.c,v 1.42 2004/03/06 19:06:04 iliaa Exp $ */
 
 #include 
 
@@ -188,7 +188,6 @@
/* mop things up if we ended on a boundary */
if (ch == base64_pad) {
switch(i % 4) {
-   case 0:
case 1:
efree(result);
return NULL;

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



[PHP-CVS] cvs: php-src /ext/standard base64.c /ext/standard/tests/strings bug24312.phpt

2003-06-24 Thread Ilia Alshanetsky
iliaa   Tue Jun 24 11:23:17 2003 EDT

  Added files: 
/php-src/ext/standard/tests/strings bug24312.phpt 

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  Fixed bug #24312 (base64_decode() does not skip 0xF0-0xFF characters)
  Patch by: gereon.steffens[at]onvista.de
  
  
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.39 php-src/ext/standard/base64.c:1.40
--- php-src/ext/standard/base64.c:1.39  Tue Jun 10 16:03:37 2003
+++ php-src/ext/standard/base64.c   Tue Jun 24 11:23:17 2003
@@ -15,7 +15,7 @@
| Author: Jim Winstead <[EMAIL PROTECTED]>  |
+--+
  */
-/* $Id: base64.c,v 1.39 2003/06/10 20:03:37 imajes Exp $ */
+/* $Id: base64.c,v 1.40 2003/06/24 15:23:17 iliaa Exp $ */
 
 #include 
 
@@ -42,6 +42,7 @@
15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, -1,
-1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, -1, -1, -1, -1, -1,
+   -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,

Index: php-src/ext/standard/tests/strings/bug24312.phpt
+++ php-src/ext/standard/tests/strings/bug24312.phpt
--TEST--
Bug #24208 (base64_decode() not skipping 0xF0 - 0xFF)
--FILE--

--EXPECT--
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""
string(100) 
""



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