systemd: merge branch 'CVE-2018-15688' into nm-1-2

This commit is contained in:
Thomas Haller 2018-10-29 21:53:38 +01:00
commit ba3f905c44
5 changed files with 30 additions and 37 deletions

View file

@ -25,7 +25,6 @@
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <string.h> #include <string.h>
#include <xlocale.h>
#include "alloc-util.h" #include "alloc-util.h"
#if 0 /* NM_IGNORED */ #if 0 /* NM_IGNORED */

View file

@ -139,8 +139,6 @@ int dhcp_network_bind_raw_socket(int ifindex, union sockaddr_union *link,
const uint8_t *bcast_addr = NULL; const uint8_t *bcast_addr = NULL;
uint8_t dhcp_hlen = 0; uint8_t dhcp_hlen = 0;
assert_return(mac_addr_len > 0, -EINVAL);
if (arp_type == ARPHRD_ETHER) { if (arp_type == ARPHRD_ETHER) {
assert_return(mac_addr_len == ETH_ALEN, -EINVAL); assert_return(mac_addr_len == ETH_ALEN, -EINVAL);
memcpy(&eth_mac, mac_addr, ETH_ALEN); memcpy(&eth_mac, mac_addr, ETH_ALEN);

View file

@ -103,7 +103,7 @@ int dhcp6_option_append_ia(uint8_t **buf, size_t *buflen, DHCP6IA *ia) {
return -EINVAL; return -EINVAL;
} }
if (*buflen < len) if (*buflen < offsetof(DHCP6Option, data) + len)
return -ENOBUFS; return -ENOBUFS;
ia_hdr = *buf; ia_hdr = *buf;
@ -341,7 +341,7 @@ int dhcp6_option_parse_ip6addrs(uint8_t *optval, uint16_t optlen,
int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char ***str_arr) { int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char ***str_arr) {
size_t pos = 0, idx = 0; size_t pos = 0, idx = 0;
_cleanup_free_ char **names = NULL; _cleanup_strv_free_ char **names = NULL;
int r; int r;
assert_return(optlen > 1, -ENODATA); assert_return(optlen > 1, -ENODATA);
@ -353,6 +353,7 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
bool first = true; bool first = true;
for (;;) { for (;;) {
const char *label;
uint8_t c; uint8_t c;
c = optval[pos++]; c = optval[pos++];
@ -360,47 +361,41 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
if (c == 0) if (c == 0)
/* End of name */ /* End of name */
break; break;
else if (c <= 63) { if (c > 63)
const char *label; return -EBADMSG;
/* Literal label */ /* Literal label */
label = (const char *)&optval[pos]; label = (const char *)&optval[pos];
pos += c; pos += c;
if (pos > optlen) if (pos >= optlen)
return -EMSGSIZE; return -EMSGSIZE;
if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX)) { if (!GREEDY_REALLOC(ret, allocated, n + !first + DNS_LABEL_ESCAPED_MAX))
r = -ENOMEM; return -ENOMEM;
goto fail;
}
if (first) if (first)
first = false; first = false;
else else
ret[n++] = '.'; ret[n++] = '.';
r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX); r = dns_label_escape(label, c, ret + n, DNS_LABEL_ESCAPED_MAX);
if (r < 0) if (r < 0)
goto fail; return r;
n += r; n += r;
continue;
} else {
r = -EBADMSG;
goto fail;
}
} }
if (!GREEDY_REALLOC(ret, allocated, n + 1)) { if (n == 0)
r = -ENOMEM; continue;
goto fail;
} if (!GREEDY_REALLOC(ret, allocated, n + 1))
return -ENOMEM;
ret[n] = 0; ret[n] = 0;
r = strv_extend(&names, ret); r = strv_extend(&names, ret);
if (r < 0) if (r < 0)
goto fail; return r;
idx++; idx++;
} }
@ -409,7 +404,4 @@ int dhcp6_option_parse_domainname(const uint8_t *optval, uint16_t optlen, char *
names = NULL; names = NULL;
return idx; return idx;
fail:
return r;
} }

View file

@ -1521,6 +1521,8 @@ static int client_handle_message(sd_dhcp_client *client, DHCPMessage *message,
client->timeout_resend = client->timeout_resend =
sd_event_source_unref(client->timeout_resend); sd_event_source_unref(client->timeout_resend);
client_notify(client, SD_DHCP_CLIENT_EVENT_EXPIRED);
r = client_initialize(client); r = client_initialize(client);
if (r < 0) if (r < 0)
goto error; goto error;

View file

@ -277,6 +277,8 @@ sd_dhcp_lease *sd_dhcp_lease_unref(sd_dhcp_lease *lease) {
free(option); free(option);
} }
free(lease->root_path);
free(lease->timezone);
free(lease->hostname); free(lease->hostname);
free(lease->domainname); free(lease->domainname);
free(lease->dns); free(lease->dns);