mirror of
https://github.com/php/php-src.git
synced 2025-01-21 11:13:38 +08:00
Merge branch 'PHP-5.6'
* PHP-5.6: Use better constant since MAXHOSTNAMELEN may mean shorter name use right sizeof for memset Conflicts: ext/sockets/sockaddr_conv.c ext/standard/dns.c
This commit is contained in:
commit
141b14454c
@ -9,11 +9,7 @@
|
||||
#include <arpa/inet.h>
|
||||
#endif
|
||||
|
||||
#ifndef MAXHOSTNAMELEN
|
||||
#define MAXHOSTNAMELEN 255
|
||||
#endif
|
||||
|
||||
extern int php_string_to_if_index(const char *val, unsigned *out);
|
||||
extern int php_string_to_if_index(const char *val, unsigned *out TSRMLS_DC);
|
||||
|
||||
#if HAVE_IPV6
|
||||
/* Sets addr by hostname, or by ip in string form (AF_INET6) */
|
||||
@ -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());
|
||||
|
@ -221,9 +221,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);
|
||||
}
|
||||
|
||||
@ -245,9 +245,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;
|
||||
}
|
||||
|
||||
|
@ -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)
|
||||
|
@ -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 {
|
||||
|
@ -319,6 +319,10 @@ END_EXTERN_C()
|
||||
|
||||
/* }}} */
|
||||
|
||||
#ifndef MAXFQDNLEN
|
||||
#define MAXFQDNLEN 255
|
||||
#endif
|
||||
|
||||
#endif /* _PHP_NETWORK_H */
|
||||
|
||||
/*
|
||||
|
@ -28,6 +28,10 @@
|
||||
#include <stdarg.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifndef MAXFQDNLEN
|
||||
#define MAXFQDNLEN 255
|
||||
#endif
|
||||
|
||||
#ifdef _WIN32
|
||||
|
||||
#include <windows.h>
|
||||
@ -616,7 +620,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);
|
||||
|
@ -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 */
|
||||
|
Loading…
Reference in New Issue
Block a user