summaryrefslogtreecommitdiff
path: root/ext/standard/cyr_convert.c
diff options
context:
space:
mode:
authorAndi Gutmans <andi@php.net>2000-06-11 17:23:38 +0000
committerAndi Gutmans <andi@php.net>2000-06-11 17:23:38 +0000
commite7c50e48664302977ad24e41180e1b6ff91c2bbb (patch)
tree30579376c6060022c1eaa9e183afee3066c04264 /ext/standard/cyr_convert.c
parent6caaf70451f6632d11ff1fd81b72f56cf681a7d6 (diff)
downloadphp-git-e7c50e48664302977ad24e41180e1b6ff91c2bbb.tar.gz
- Untested but it should fix the problem with cyr_convert() not being
- binary safe and destroying other values in the script
Diffstat (limited to 'ext/standard/cyr_convert.c')
-rw-r--r--ext/standard/cyr_convert.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/ext/standard/cyr_convert.c b/ext/standard/cyr_convert.c
index c5919b58c0..921552ba55 100644
--- a/ext/standard/cyr_convert.c
+++ b/ext/standard/cyr_convert.c
@@ -202,7 +202,7 @@ _cyr_mac = {
* d - x-cp866
* m - x-mac-cyrillic
*****************************************************************************/
-static char * php_convert_cyr_string(unsigned char *str, char from, char to)
+static char * php_convert_cyr_string(unsigned char *str, int length, char from, char to)
{
const unsigned char *from_table, *to_table;
unsigned char tmp;
@@ -259,7 +259,7 @@ static char * php_convert_cyr_string(unsigned char *str, char from, char to)
if (!str)
return (char *)str;
- for( i = 0; str[i]; i++)
+ for( i = 0; i<length; i++)
{
tmp = (from_table == NULL)? str[i] : from_table[ str[i] ];
str[i] = (to_table == NULL) ? tmp : to_table[tmp + 256];
@@ -282,9 +282,9 @@ PHP_FUNCTION(convert_cyr_string)
convert_to_string_ex(fr_cs);
convert_to_string_ex(to_cs);
- str = (unsigned char*) (*str_arg)->value.str.val;
+ str = (unsigned char*) estrndup((*str_arg)->value.str.val, (*str_arg)->value.str.len);
- php_convert_cyr_string(str, (*fr_cs)->value.str.val[0],(*to_cs)->value.str.val[0]);
- RETVAL_STRING((char *)str, 1)
+ php_convert_cyr_string(str, (*str_arg)->value.str.len, (*fr_cs)->value.str.val[0], (*to_cs)->value.str.val[0]);
+ RETVAL_STRING((char *)str, 0)
}
/* }}} */