diff options
author | Sascha Schumann <sas@php.net> | 2003-02-08 18:58:34 +0000 |
---|---|---|
committer | Sascha Schumann <sas@php.net> | 2003-02-08 18:58:34 +0000 |
commit | a0d1331137ecbebfba093d7093f17d700ee70e4d (patch) | |
tree | 6cd210e7cf77dade31a0430242c38f039f635aed | |
parent | 0bce25794719c6b64c52e4c1302afb3f3b0822ae (diff) | |
download | php-git-a0d1331137ecbebfba093d7093f17d700ee70e4d.tar.gz |
Fix segfault in bindtextdomain when first parameter was empty.
The Linux man page states: domainname must be a non-empty string.
Noticed by: Nils Meyer
-rw-r--r-- | ext/gettext/gettext.c | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/ext/gettext/gettext.c b/ext/gettext/gettext.c index d384e22667..4b41a57d4b 100644 --- a/ext/gettext/gettext.c +++ b/ext/gettext/gettext.c @@ -178,7 +178,12 @@ PHP_FUNCTION(bindtextdomain) convert_to_string_ex(domain_name); convert_to_string_ex(dir); - if (strcmp(Z_STRVAL_PP(dir), "") && strcmp(Z_STRVAL_PP(dir), "0")) { + if (Z_STRVAL_PP(domain_name)[0] == '\0') { + php_error(E_WARNING, "The first parameter of bindtextdomain must not be empty"); + RETURN_FALSE; + } + + if (Z_STRVAL_PP(dir)[0] != '\0' && strcmp(Z_STRVAL_PP(dir), "0")) { VCWD_REALPATH(Z_STRVAL_PP(dir), dir_name); } else { VCWD_GETCWD(dir_name, MAXPATHLEN); |