1
0
mirror of https://github.com/php/php-src.git synced 2026-03-27 01:32:22 +01:00

Fixed bug #41347 (checkdnsrr() segfaults on empty hostname).

This commit is contained in:
Scott MacVicar
2007-05-10 13:16:54 +00:00
parent c69b76dc52
commit e7577d57cd
3 changed files with 32 additions and 0 deletions

1
NEWS
View File

@@ -7,6 +7,7 @@ PHP NEWS
(Ilia)
- Fixed altering $this via argument named "this". (Dmitry)
- Fixed PHP CLI to use the php.ini from the binary location. (Hannes)
- Fixed bug #41347 (checkdnsrr() segfaults on empty hostname). (Scott)
- Fixed bug #41326 (Writing empty tags with Xmlwriter::WriteElement[ns])
(Pierre)
- Fixed bug #41321 (downgrade read errors in getimagesize() to E_NOTICE).

View File

@@ -264,6 +264,12 @@ PHP_FUNCTION(dns_check_record)
}
type = T_MX;
convert_to_string_ex(arg1);
if (Z_STRLEN_PP(arg1) == 0)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host cannot be empty");
RETURN_FALSE;
}
break;
case 2:
@@ -273,6 +279,12 @@ PHP_FUNCTION(dns_check_record)
convert_to_string_ex(arg1);
convert_to_string_ex(arg2);
if (Z_STRLEN_PP(arg1) == 0 || Z_STRLEN_PP(arg2) == 0)
{
php_error_docref(NULL TSRMLS_CC, E_WARNING, "Host and type cannot be empty");
RETURN_FALSE;
}
if (!strcasecmp("A", Z_STRVAL_PP(arg2))) type = T_A;
else if (!strcasecmp("NS", Z_STRVAL_PP(arg2))) type = DNS_T_NS;
else if (!strcasecmp("MX", Z_STRVAL_PP(arg2))) type = DNS_T_MX;

View File

@@ -0,0 +1,19 @@
--TEST--
dns_check_record() segfault with empty host
--SKIPIF--
<?php
if (substr(PHP_OS, 0, 3) == 'WIN') {
die('No windows support');
}
?>
--FILE--
<?php
var_dump(dns_check_record(''));
var_dump(dns_check_record('', ''));
?>
--EXPECTF--
Warning: dns_check_record(): Host cannot be empty in %s on line %d
bool(false)
Warning: dns_check_record(): Host and type cannot be empty in %s on line %d
bool(false)