summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStanislav Malyshev <stas@php.net>2015-01-31 21:47:22 -0800
committerStanislav Malyshev <stas@php.net>2015-01-31 21:48:14 -0800
commitaf1f867308ca68e82a2143f62ecd7a6f7b19ba2a (patch)
tree421421ca2b706e063eafdc2f0ea38b0037139bf1
parent882a375dbad4ecb1fddd9dd80f1a1350299629c1 (diff)
parentb30a6d6018705e0a9d345192eba8125ff854c167 (diff)
downloadphp-git-af1f867308ca68e82a2143f62ecd7a6f7b19ba2a.tar.gz
Merge branch 'PHP-5.4' into PHP-5.5
* PHP-5.4: Use better constant since MAXHOSTNAMELEN may mean shorter name use right sizeof for memset
-rw-r--r--ext/sockets/sockaddr_conv.c6
-rw-r--r--ext/standard/dns.c8
-rw-r--r--ext/standard/tests/network/bug68925.phpt4
-rw-r--r--main/network.c6
-rw-r--r--main/php_network.h4
-rw-r--r--sapi/cgi/fastcgi.c6
-rw-r--r--sapi/litespeed/lsapilib.c2
7 files changed, 18 insertions, 18 deletions
diff --git a/ext/sockets/sockaddr_conv.c b/ext/sockets/sockaddr_conv.c
index 80807dd243..961896bdab 100644
--- a/ext/sockets/sockaddr_conv.c
+++ b/ext/sockets/sockaddr_conv.c
@@ -9,10 +9,6 @@
#include <arpa/inet.h>
#endif
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 255
-#endif
-
extern int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC);
#if HAVE_IPV6
@@ -94,7 +90,7 @@ int php_set_inet_addr(struct sockaddr_in *sin, char *string, php_socket *php_soc
if (inet_aton(string, &tmp)) {
sin->sin_addr.s_addr = tmp.s_addr;
} else {
- if (strlen(string) > MAXHOSTNAMELEN || ! (host_entry = gethostbyname(string))) {
+ if (strlen(string) > MAXFQDNLEN || ! (host_entry = gethostbyname(string))) {
/* Note: < -10000 indicates a host lookup error */
#ifdef PHP_WIN32
PHP_SOCKET_ERROR(php_sock, "Host lookup failed", WSAGetLastError());
diff --git a/ext/standard/dns.c b/ext/standard/dns.c
index bb5f9109ed..8b93b717c6 100644
--- a/ext/standard/dns.c
+++ b/ext/standard/dns.c
@@ -222,9 +222,9 @@ PHP_FUNCTION(gethostbyname)
return;
}
- if(hostname_len > MAXHOSTNAMELEN) {
+ if(hostname_len > MAXFQDNLEN) {
/* name too long, protect from CVE-2015-0235 */
- php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXHOSTNAMELEN);
+ php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN);
RETURN_STRINGL(hostname, hostname_len, 1);
}
addr = php_gethostbyname(hostname);
@@ -247,9 +247,9 @@ PHP_FUNCTION(gethostbynamel)
return;
}
- if(hostname_len > MAXHOSTNAMELEN) {
+ if(hostname_len > MAXFQDNLEN) {
/* name too long, protect from CVE-2015-0235 */
- php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXHOSTNAMELEN);
+ php_error_docref(NULL, E_WARNING, "Host name is too long, the limit is %d characters", MAXFQDNLEN);
RETURN_FALSE;
}
diff --git a/ext/standard/tests/network/bug68925.phpt b/ext/standard/tests/network/bug68925.phpt
index e710d72bdf..2638dd331d 100644
--- a/ext/standard/tests/network/bug68925.phpt
+++ b/ext/standard/tests/network/bug68925.phpt
@@ -6,8 +6,8 @@ var_dump(gethostbyname(str_repeat("0", 2501)));
var_dump(gethostbynamel(str_repeat("0", 2501)));
?>
--EXPECTF--
-Warning: gethostbyname(): Host name is too long, the limit is 256 characters in %s/bug68925.php on line %d
+Warning: gethostbyname(): Host name is too long, the limit is %d characters in %s/bug68925.php on line %d
string(2501) "00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"
-Warning: gethostbynamel(): Host name is too long, the limit is 256 characters in %s/bug68925.php on line %d
+Warning: gethostbynamel(): Host name is too long, the limit is %d characters in %s/bug68925.php on line %d
bool(false)
diff --git a/main/network.c b/main/network.c
index c93e366cc6..636afc62b0 100644
--- a/main/network.c
+++ b/main/network.c
@@ -105,10 +105,6 @@ const struct in6_addr in6addr_any = {0}; /* IN6ADDR_ANY_INIT; */
# define PHP_TIMEOUT_ERROR_VALUE ETIMEDOUT
#endif
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 255
-#endif
-
#if HAVE_GETADDRINFO
#ifdef HAVE_GAI_STRERROR
# define PHP_GAI_STRERROR(x) (gai_strerror(x))
@@ -250,7 +246,7 @@ PHPAPI int php_network_getaddresses(const char *host, int socktype, struct socka
#else
if (!inet_aton(host, &in)) {
/* XXX NOT THREAD SAFE (is safe under win32) */
- if(strlen(host) > MAXHOSTNAMELEN) {
+ if(strlen(host) > MAXFQDNLEN) {
host_info = NULL;
errno = E2BIG;
} else {
diff --git a/main/php_network.h b/main/php_network.h
index 37ad395af0..8dc4e0aa60 100644
--- a/main/php_network.h
+++ b/main/php_network.h
@@ -313,6 +313,10 @@ END_EXTERN_C()
/* }}} */
+#ifndef MAXFQDNLEN
+#define MAXFQDNLEN 255
+#endif
+
#endif /* _PHP_NETWORK_H */
/*
diff --git a/sapi/cgi/fastcgi.c b/sapi/cgi/fastcgi.c
index 7d39d6139b..98d503ec72 100644
--- a/sapi/cgi/fastcgi.c
+++ b/sapi/cgi/fastcgi.c
@@ -27,6 +27,10 @@
#include <stdarg.h>
#include <errno.h>
+#ifndef MAXFQDNLEN
+#define MAXFQDNLEN 255
+#endif
+
#ifdef _WIN32
#include <windows.h>
@@ -611,7 +615,7 @@ int fcgi_listen(const char *path, int backlog)
if (sa.sa_inet.sin_addr.s_addr == INADDR_NONE) {
struct hostent *hep;
- if(strlen(host) > MAXHOSTNAMELEN) {
+ if(strlen(host) > MAXFQDNLEN) {
hep = NULL;
} else {
hep = gethostbyname(host);
diff --git a/sapi/litespeed/lsapilib.c b/sapi/litespeed/lsapilib.c
index 56ec0d3f2f..039d91dcd9 100644
--- a/sapi/litespeed/lsapilib.c
+++ b/sapi/litespeed/lsapilib.c
@@ -3376,7 +3376,7 @@ void lsapi_MD5Final(unsigned char digest[16], struct lsapi_MD5Context *ctx)
lsapi_MD5Transform(ctx->buf, (uint32 *) ctx->in);
byteReverse((unsigned char *) ctx->buf, 4);
memmove(digest, ctx->buf, 16);
- memset(ctx, 0, sizeof(ctx)); /* In case it's sensitive */
+ memset(ctx, 0, sizeof(*ctx)); /* In case it's sensitive */
}
/* The four core functions - F1 is optimized somewhat */