Репозитории ALT
S: | 9.4.0-alt2 |
D: | 4.0.0-alt0.1.rc4 |
5.1: | 4.0.15-alt4.M51.1 |
4.1: | 3.0.17-alt4 |
4.0: | 3.0.17-alt2.M40.1 |
3.0: | 1.3.22pl4-alt3 |
+backports: | 3.0.17-alt3.M30 |
Группа :: Система/Серверы
Пакет: dhcpcd
Главная Изменения Спек Патчи Sources Загрузить Gear Bugs and FR Repocop
Патч: dhcpcd-3.0.17-alt-backport-3.1.0.patch
Скачать
Скачать
diff -Naur dhcpcd-3.0.17.orig/configure.c dhcpcd-3.0.17/configure.c
--- dhcpcd-3.0.17.orig/configure.c 2007-05-14 14:27:21 +0400
+++ dhcpcd-3.0.17/configure.c 2007-05-21 14:54:55 +0400
@@ -620,24 +620,48 @@
/* Now we have made a resolv.conf we can obtain a hostname if we need one */
if (options->dohostname && ! dhcp->hostname) {
- he = gethostbyaddr (inet_ntoa (dhcp->address),
- sizeof (struct in_addr), AF_INET);
- if (he) {
- dname = he->h_name;
- while (*dname > 32)
- dname++;
- dnamel = dname - he->h_name;
- memcpy (newhostname, he->h_name, dnamel);
- newhostname[dnamel] = 0;
+ union {
+ struct sockaddr sa;
+ struct sockaddr_in sin;
+ } su;
+ socklen_t salen;
+ char addr[NI_MAXHOST];
+ struct addrinfo hints, *res;
+ int result;
+
+ salen = sizeof (struct sockaddr);
+ memset (&su.sa, 0, salen);
+ su.sin.sin_family = AF_INET;
+ memcpy (&su.sin.sin_addr, &dhcp->address, sizeof (struct in_addr));
+
+ logger (LOG_DEBUG, "Looking up hostname via DNS");
+ if ((result = getnameinfo (&su.sa, salen, addr, sizeof (addr),
+ NULL, 0, NI_NAMEREQD)) != 0)
+ logger (LOG_ERR, "Failed to lookup hostname via DNS: %s", gai_strerror (result));
+ else {
+ /* Check for a malicious PTR record */
+ memset (&hints, 0, sizeof (hints));
+ hints.ai_socktype = SOCK_DGRAM;
+ hints.ai_flags = AI_NUMERICHOST;
+ if (getaddrinfo (addr, "0", &hints, &res) == 0) {
+ freeaddrinfo (res);
+ addr[0] = '\0';
+ logger (LOG_ERR, "malicious PTR record detected");
+ } else if (*addr) {
+ strlcpy(newhostname,addr, sizeof (newhostname));
+ /* strange logic from upstream was here ... */
+ }
}
}
+
gethostname (curhostname, sizeof (curhostname));
if (options->dohostname
|| strlen (curhostname) == 0
|| strcmp (curhostname, "(none)") == 0
- || strcmp (curhostname, "localhost") == 0)
+ || strcmp (curhostname, "localhost") == 0
+ || strcmp (curhostname, "localhost.localdomain") == 0)
{
if (dhcp->hostname)
strlcpy (newhostname, dhcp->hostname, sizeof (newhostname));