|
|
a03026 |
From 3947ab0069e443e72debe26379b8517fac8f6e41 Mon Sep 17 00:00:00 2001
|
|
|
a03026 |
From: Simon Kelley <simon@thekelleys.org.uk>
|
|
|
a03026 |
Date: Mon, 25 Sep 2017 20:19:55 +0100
|
|
|
a03026 |
Subject: [PATCH 8/9] Misc code cleanups arising from Google analysis.
|
|
|
a03026 |
No security impleications or CVEs.
|
|
|
a03026 |
|
|
|
a03026 |
---
|
|
|
a03026 |
src/edns0.c | 2 +-
|
|
|
a03026 |
src/rfc1035.c | 4 +++-
|
|
|
a03026 |
src/rfc2131.c | 2 +-
|
|
|
a03026 |
3 files changed, 5 insertions(+), 3 deletions(-)
|
|
|
a03026 |
|
|
|
a03026 |
diff --git a/src/edns0.c b/src/edns0.c
|
|
|
a03026 |
index a8d0167..0552d38 100644
|
|
|
a03026 |
--- a/src/edns0.c
|
|
|
a03026 |
+++ b/src/edns0.c
|
|
|
a03026 |
@@ -159,7 +159,7 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
|
|
|
a03026 |
/* delete option if we're to replace it. */
|
|
|
a03026 |
p -= 4;
|
|
|
a03026 |
rdlen -= len + 4;
|
|
|
a03026 |
- memcpy(p, p+len+4, rdlen - i);
|
|
|
a03026 |
+ memmove(p, p+len+4, rdlen - i);
|
|
|
a03026 |
PUTSHORT(rdlen, lenp);
|
|
|
a03026 |
lenp -= 2;
|
|
|
a03026 |
}
|
|
|
a03026 |
diff --git a/src/rfc1035.c b/src/rfc1035.c
|
|
|
a03026 |
index 78410d6..917bac2 100644
|
|
|
a03026 |
--- a/src/rfc1035.c
|
|
|
a03026 |
+++ b/src/rfc1035.c
|
|
|
a03026 |
@@ -37,7 +37,7 @@ int extract_name(struct dns_header *header, size_t plen, unsigned char **pp,
|
|
|
a03026 |
/* end marker */
|
|
|
a03026 |
{
|
|
|
a03026 |
/* check that there are the correct no of bytes after the name */
|
|
|
a03026 |
- if (!CHECK_LEN(header, p, plen, extrabytes))
|
|
|
a03026 |
+ if (!CHECK_LEN(header, p1 ? p1 : p, plen, extrabytes))
|
|
|
a03026 |
return 0;
|
|
|
a03026 |
|
|
|
a03026 |
if (isExtract)
|
|
|
a03026 |
@@ -485,6 +485,8 @@ static unsigned char *do_doctor(unsigned char *p, int count, struct dns_header *
|
|
|
a03026 |
{
|
|
|
a03026 |
unsigned int i, len = *p1;
|
|
|
a03026 |
unsigned char *p2 = p1;
|
|
|
a03026 |
+ if ((p1 + len - p) >= rdlen)
|
|
|
a03026 |
+ return 0; /* bad packet */
|
|
|
a03026 |
/* make counted string zero-term and sanitise */
|
|
|
a03026 |
for (i = 0; i < len; i++)
|
|
|
a03026 |
{
|
|
|
a03026 |
diff --git a/src/rfc2131.c b/src/rfc2131.c
|
|
|
a03026 |
index 75893a6..71d5846 100644
|
|
|
a03026 |
--- a/src/rfc2131.c
|
|
|
a03026 |
+++ b/src/rfc2131.c
|
|
|
a03026 |
@@ -155,7 +155,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
|
|
|
a03026 |
for (offset = 0; offset < (len - 5); offset += elen + 5)
|
|
|
a03026 |
{
|
|
|
a03026 |
elen = option_uint(opt, offset + 4 , 1);
|
|
|
a03026 |
- if (option_uint(opt, offset, 4) == BRDBAND_FORUM_IANA)
|
|
|
a03026 |
+ if (option_uint(opt, offset, 4) == BRDBAND_FORUM_IANA && offset + elen + 5 <= len)
|
|
|
a03026 |
{
|
|
|
a03026 |
unsigned char *x = option_ptr(opt, offset + 5);
|
|
|
a03026 |
unsigned char *y = option_ptr(opt, offset + elen + 5);
|
|
|
a03026 |
--
|
|
|
a03026 |
2.9.5
|
|
|
a03026 |
|