1
0
mirror of https://github.com/php/php-src.git synced 2026-03-24 00:02:20 +01:00

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
This commit is contained in:
Stanislav Malyshev
2015-01-31 21:47:22 -08:00
7 changed files with 18 additions and 18 deletions

View File

@@ -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());

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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 {

View File

@@ -313,6 +313,10 @@ END_EXTERN_C()
/* }}} */
#ifndef MAXFQDNLEN
#define MAXFQDNLEN 255
#endif
#endif /* _PHP_NETWORK_H */
/*

View File

@@ -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);

View File

@@ -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 */