iliaa Sat Feb 24 17:18:24 2007 UTC
Modified files: (Branch: PHP_5_2)
/php-src/ext/standard html.c
Log:
Eliminate strncpy() and simplify code
http://cvs.php.net/viewvc.cgi/php-src/ext/standard/html.c?r1=1.111.2.2.2.7&r2=1.111.2.2.2.8&diff_format=u
Index: php-src/ext/standard/html.c
diff -u php-src/ext/standard/html.c:1.111.2.2.2.7
php-src/ext/standard/html.c:1.111.2.2.2.8
--- php-src/ext/standard/html.c:1.111.2.2.2.7 Wed Feb 21 03:59:05 2007
+++ php-src/ext/standard/html.c Sat Feb 24 17:18:24 2007
@@ -18,7 +18,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: html.c,v 1.111.2.2.2.7 2007/02/21 03:59:05 iliaa Exp $ */
+/* $Id: html.c,v 1.111.2.2.2.8 2007/02/24 17:18:24 iliaa Exp $ */
/*
* HTML entity resources:
@@ -912,12 +912,10 @@
if (entity_map[j].table[k -
entity_map[j].basechar] == NULL)
continue;
- entity[0] = '&';
- entity_length = strlen(entity_map[j].table[k -
entity_map[j].basechar]);
- strncpy(&entity[1], entity_map[j].table[k -
entity_map[j].basechar], sizeof(entity) - 2);
- entity[entity_length+1] = ';';
- entity[entity_length+2] = '\0';
- entity_length += 2;
+ entity_length = snprintf(entity,
sizeof(entity), "&%s;", entity_map[j].table[k - entity_map[j].basechar]);
+ if (entity_length >= sizeof(entity)) {
+ continue;
+ }
/* When we have MBCS entities in the tables
above, this will need to handle it */
replacement_len = 0;
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php