mirror of
https://github.com/systemd/systemd-stable.git
synced 2024-12-28 07:21:32 +03:00
resolved: simplify alloc size calculation
The allocation size was calculated in a complicated way, and for values close to the page size we would actually allocate less than requested. Reported by Chris Coulson <chris.coulson@canonical.com>. CVE-2017-9445
This commit is contained in:
parent
751ca3f1de
commit
db848813ba
@ -47,13 +47,7 @@ int dns_packet_new(DnsPacket **ret, DnsProtocol protocol, size_t mtu) {
|
||||
|
||||
assert(ret);
|
||||
|
||||
if (mtu <= UDP_PACKET_HEADER_SIZE)
|
||||
a = DNS_PACKET_SIZE_START;
|
||||
else
|
||||
a = mtu - UDP_PACKET_HEADER_SIZE;
|
||||
|
||||
if (a < DNS_PACKET_HEADER_SIZE)
|
||||
a = DNS_PACKET_HEADER_SIZE;
|
||||
a = MAX(mtu, DNS_PACKET_HEADER_SIZE);
|
||||
|
||||
/* round up to next page size */
|
||||
a = PAGE_ALIGN(ALIGN(sizeof(DnsPacket)) + a) - ALIGN(sizeof(DnsPacket));
|
||||
|
@ -66,8 +66,6 @@ struct DnsPacketHeader {
|
||||
/* With EDNS0 we can use larger packets, default to 4096, which is what is commonly used */
|
||||
#define DNS_PACKET_UNICAST_SIZE_LARGE_MAX 4096
|
||||
|
||||
#define DNS_PACKET_SIZE_START 512
|
||||
|
||||
struct DnsPacket {
|
||||
int n_ref;
|
||||
DnsProtocol protocol;
|
||||
|
Loading…
Reference in New Issue
Block a user