Revert "Revert "oran-shell-release: release image for F""
[pti/rtp.git] / meta-starlingx / meta-stx-integ / recipes-support / dnsmasq / dnsmasq / stx / dnsmasq-2.76-misc-cleanups.patch
1 From 3947ab0069e443e72debe26379b8517fac8f6e41 Mon Sep 17 00:00:00 2001
2 From: Simon Kelley <simon@thekelleys.org.uk>
3 Date: Mon, 25 Sep 2017 20:19:55 +0100
4 Subject: [PATCH 8/9]     Misc code cleanups arising from Google analysis.    
5  No security impleications or CVEs.
6
7 ---
8  src/edns0.c   | 2 +-
9  src/rfc1035.c | 4 +++-
10  src/rfc2131.c | 2 +-
11  3 files changed, 5 insertions(+), 3 deletions(-)
12
13 diff --git a/src/edns0.c b/src/edns0.c
14 index a8d0167..0552d38 100644
15 --- a/src/edns0.c
16 +++ b/src/edns0.c
17 @@ -159,7 +159,7 @@ size_t add_pseudoheader(struct dns_header *header, size_t plen, unsigned char *l
18               /* delete option if we're to replace it. */
19               p -= 4;
20               rdlen -= len + 4;
21 -             memcpy(p, p+len+4, rdlen - i);
22 +             memmove(p, p+len+4, rdlen - i);
23               PUTSHORT(rdlen, lenp);
24               lenp -= 2;
25             }
26 diff --git a/src/rfc1035.c b/src/rfc1035.c
27 index 78410d6..917bac2 100644
28 --- a/src/rfc1035.c
29 +++ b/src/rfc1035.c
30 @@ -37,7 +37,7 @@ int extract_name(struct dns_header *header, size_t plen, unsigned char **pp,
31         /* end marker */
32         {
33           /* check that there are the correct no of bytes after the name */
34 -         if (!CHECK_LEN(header, p, plen, extrabytes))
35 +         if (!CHECK_LEN(header, p1 ? p1 : p, plen, extrabytes))
36             return 0;
37           
38           if (isExtract)
39 @@ -485,6 +485,8 @@ static unsigned char *do_doctor(unsigned char *p, int count, struct dns_header *
40             {
41               unsigned int i, len = *p1;
42               unsigned char *p2 = p1;
43 +             if ((p1 + len - p) >= rdlen)
44 +               return 0; /* bad packet */
45               /* make counted string zero-term  and sanitise */
46               for (i = 0; i < len; i++)
47                 {
48 diff --git a/src/rfc2131.c b/src/rfc2131.c
49 index 75893a6..71d5846 100644
50 --- a/src/rfc2131.c
51 +++ b/src/rfc2131.c
52 @@ -155,7 +155,7 @@ size_t dhcp_reply(struct dhcp_context *context, char *iface_name, int int_index,
53           for (offset = 0; offset < (len - 5); offset += elen + 5)
54             {
55               elen = option_uint(opt, offset + 4 , 1);
56 -             if (option_uint(opt, offset, 4) == BRDBAND_FORUM_IANA)
57 +             if (option_uint(opt, offset, 4) == BRDBAND_FORUM_IANA && offset + elen + 5 <= len)
58                 {
59                   unsigned char *x = option_ptr(opt, offset + 5);
60                   unsigned char *y = option_ptr(opt, offset + elen + 5);
61 -- 
62 2.9.5
63