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

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

  Added files: (Branch: PHP_5_3)
/php-src/ext/standard/tests/url bug47174.phpt 

  Modified files:  
/php-src/ext/standard   base64.c 
  Log:
  Improved fix for bug #47174  added a test
  
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.43.2.2.2.3.2.5r2=1.43.2.2.2.3.2.6diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.43.2.2.2.3.2.5 
php-src/ext/standard/base64.c:1.43.2.2.2.3.2.6
--- php-src/ext/standard/base64.c:1.43.2.2.2.3.2.5  Wed Jan 21 15:38:37 2009
+++ php-src/ext/standard/base64.c   Sun Jan 25 18:27:11 2009
@@ -15,7 +15,7 @@
| Author: Jim Winstead j...@php.net  |
+--+
  */
-/* $Id: base64.c,v 1.43.2.2.2.3.2.5 2009/01/21 15:38:37 iliaa Exp $ */
+/* $Id: base64.c,v 1.43.2.2.2.3.2.6 2009/01/25 18:27:11 iliaa Exp $ */
 
 #include string.h
 
@@ -156,7 +156,6 @@
efree(result);
return NULL;
}
-   i++;
continue;
}
 

http://cvs.php.net/viewvc.cgi/php-src/ext/standard/tests/url/bug47174.phpt?view=markuprev=1.1
Index: php-src/ext/standard/tests/url/bug47174.phpt
+++ php-src/ext/standard/tests/url/bug47174.phpt



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



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

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

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   base64.c 
  Log:
  
  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.43.2.2.2.3.2.4r2=1.43.2.2.2.3.2.5diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.43.2.2.2.3.2.4 
php-src/ext/standard/base64.c:1.43.2.2.2.3.2.5
--- php-src/ext/standard/base64.c:1.43.2.2.2.3.2.4  Wed Dec 31 11:15:44 2008
+++ php-src/ext/standard/base64.c   Wed Jan 21 15:38:37 2009
@@ -15,7 +15,7 @@
| Author: Jim Winstead j...@php.net  |
+--+
  */
-/* $Id: base64.c,v 1.43.2.2.2.3.2.4 2008/12/31 11:15:44 sebastian Exp $ */
+/* $Id: base64.c,v 1.43.2.2.2.3.2.5 2009/01/21 15:38:37 iliaa Exp $ */
 
 #include string.h
 
@@ -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(PHP_5_3) /ext/standard base64.c

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

  Modified files:  (Branch: PHP_5_3)
/php-src/ext/standard   base64.c 
  Log:
  MFH
  
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/base64.c?r1=1.43.2.2.2.3r2=1.43.2.2.2.3.2.1diff_format=u
Index: php-src/ext/standard/base64.c
diff -u php-src/ext/standard/base64.c:1.43.2.2.2.3 
php-src/ext/standard/base64.c:1.43.2.2.2.3.2.1
--- php-src/ext/standard/base64.c:1.43.2.2.2.3  Sat Jul 21 01:24:26 2007
+++ php-src/ext/standard/base64.c   Mon Nov  5 12:07:37 2007
@@ -15,21 +15,21 @@
| Author: Jim Winstead [EMAIL PROTECTED]  
|
+--+
  */
-/* $Id: base64.c,v 1.43.2.2.2.3 2007/07/21 01:24:26 jani Exp $ */
+/* $Id: base64.c,v 1.43.2.2.2.3.2.1 2007/11/05 12:07:37 jani Exp $ */
 
 #include string.h
 
 #include php.h
 #include base64.h
 
-/* {{{ */
-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'
-   };
+/* {{{ 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_pad = '=';
 
@@ -53,8 +53,7 @@
 };
 /* }}} */
 
-/* {{{ php_base64_encode */
-PHPAPI unsigned char *php_base64_encode(const unsigned char *str, int length, 
int *ret_length)
+PHPAPI unsigned char *php_base64_encode(const unsigned char *str, int length, 
int *ret_length) /* {{{ */
 {
const unsigned char *current = str;
unsigned char *p;
@@ -135,21 +134,20 @@
 */
 /* }}} */
 
-PHPAPI unsigned char *php_base64_decode(const unsigned char *str, int length, 
int *ret_length)
+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_ex(const unsigned char *str, int 
length, int *ret_length, zend_bool strict)
+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;
/* this sucks for threaded environments */
unsigned char *result;
-   
-   result = (unsigned char *)emalloc(length + 1);
+
+   result = (unsigned char *)safe_emalloc(length, 1, 1);
 
/* run through the whole string, converting as we go */
while ((ch = *current++) != '\0'  length--  0) {
@@ -214,16 +212,15 @@
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, str, 
str_len) == FAILURE) {
return;
}
-   result = php_base64_encode(str, str_len, ret_length);
+   result = php_base64_encode((unsigned char*)str, str_len, ret_length);
if (result != NULL) {
-   RETVAL_STRINGL(result, ret_length, 0);
+   RETVAL_STRINGL((char*)result, ret_length, 0);
} else {
RETURN_FALSE;
}
 }
 /* }}} */
 
-
 /* {{{ proto string base64_decode(string str[, bool strict])
Decodes string using MIME base64 algorithm */
 PHP_FUNCTION(base64_decode)
@@ -236,16 +233,15 @@
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(result, ret_length, 0);
+   RETVAL_STRINGL((char*)result, ret_length, 0);
} else {
RETURN_FALSE;
}
 }
 /* }}} */
 
-
 /*
  * Local variables:
  * tab-width: 4

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