iliaa Wed Oct 29 20:29:13 2008 UTC
Modified files: (Branch: PHP_5_3)
/php-src/ext/gettext gettext.c
Log:
Fixed bug #44938 (gettext functions crash with overly long domain)
http://cvs.php.net/viewvc.cgi/php-src/ext/gettext/gettext.c?r1=1.46.2.2.2.4.2.4&r2=1.46.2.2.2.4.2.5&diff_format=u
Index: php-src/ext/gettext/gettext.c
diff -u php-src/ext/gettext/gettext.c:1.46.2.2.2.4.2.4
php-src/ext/gettext/gettext.c:1.46.2.2.2.4.2.5
--- php-src/ext/gettext/gettext.c:1.46.2.2.2.4.2.4 Fri Oct 24 14:35:34 2008
+++ php-src/ext/gettext/gettext.c Wed Oct 29 20:29:12 2008
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: gettext.c,v 1.46.2.2.2.4.2.4 2008/10/24 14:35:34 felipe Exp $ */
+/* $Id: gettext.c,v 1.46.2.2.2.4.2.5 2008/10/29 20:29:12 iliaa Exp $ */
#ifdef HAVE_CONFIG_H
#include "config.h"
@@ -135,6 +135,13 @@
ZEND_GET_MODULE(php_gettext)
#endif
+#define PHP_GETTEXT_MAX_DOMAIN_LENGTH 1024
+#define PHP_GETTEXT_DOMAIN_LENGTH_CHECK \
+ if (domain_len > PHP_GETTEXT_MAX_DOMAIN_LENGTH) { \
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "domain passed too
long"); \
+ RETURN_FALSE; \
+ }
+
PHP_MINFO_FUNCTION(php_gettext)
{
php_info_print_table_start();
@@ -153,6 +160,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
if (strcmp(domain, "") && strcmp(domain, "0")) {
domain_name = domain;
} else {
@@ -193,6 +202,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
msgstr = dgettext(domain, msgid);
RETURN_STRING(msgstr, 1);
@@ -211,6 +222,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
msgstr = dcgettext(domain, msgid, category);
RETURN_STRING(msgstr, 1);
@@ -229,6 +242,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
if (domain[0] == '\0') {
php_error(E_WARNING, "The first parameter of bindtextdomain
must not be empty");
RETURN_FALSE;
@@ -283,6 +298,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
msgstr = dngettext(domain, msgid1, msgid2, count);
if (msgstr) {
RETVAL_STRING(msgstr, 1);
@@ -307,6 +324,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
msgstr = dcngettext(domain, msgid1, msgid2, count, category);
if (msgstr) {
@@ -329,6 +348,8 @@
return;
}
+ PHP_GETTEXT_DOMAIN_LENGTH_CHECK
+
retval = bind_textdomain_codeset(domain, codeset);
if (!retval) {
--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php