49 lines
1.3 KiB
Diff
49 lines
1.3 KiB
Diff
From 46b9670a418419d9e04bbe9a0d6c5a85f3c63265 Mon Sep 17 00:00:00 2001
|
|
From: Doran Moppert <dmoppert@redhat.com>
|
|
Date: Tue, 26 Sep 2017 14:48:20 +0930
|
|
Subject: [PATCH] google patch hand-applied
|
|
|
|
---
|
|
src/edns0.c | 10 +++++-----
|
|
src/rfc1035.c | 3 +++
|
|
2 files changed, 8 insertions(+), 5 deletions(-)
|
|
|
|
diff --git a/src/edns0.c b/src/edns0.c
|
|
index c498eb1..0eb3873 100644
|
|
--- a/src/edns0.c
|
|
+++ b/src/edns0.c
|
|
@@ -212,11 +212,11 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
|
|
/* Copy back any options */
|
|
if (buff)
|
|
{
|
|
- if (p + rdlen > limit)
|
|
- {
|
|
- free(buff);
|
|
- return plen; /* Too big */
|
|
- }
|
|
+ if (p + rdlen > limit)
|
|
+ {
|
|
+ free(buff);
|
|
+ return plen; /* Too big */
|
|
+ }
|
|
memcpy(p, buff, rdlen);
|
|
free(buff);
|
|
p += rdlen;
|
|
diff --git a/src/rfc1035.c b/src/rfc1035.c
|
|
index 60ef272..93701f6 100644
|
|
--- a/src/rfc1035.c
|
|
+++ b/src/rfc1035.c
|
|
@@ -1411,6 +1411,9 @@ size_t answer_request(struct dns_header *header, char *limit, size_t qlen,
|
|
size_t len;
|
|
int rd_bit = (header->hb3 & HB3_RD);
|
|
|
|
+ // Make sure we do not underflow here too.
|
|
+ if (qlen > (limit - ((char *)header))) return 0;
|
|
+
|
|
/* never answer queries with RD unset, to avoid cache snooping. */
|
|
if (ntohs(header->ancount) != 0 ||
|
|
ntohs(header->nscount) != 0 ||
|
|
--
|
|
2.37.3
|
|
|