Code

patches/CVE-2016-6254.dpatch: Fix heap overflow in the network plugin.
[pkg-collectd.git] / debian / patches / CVE-2016-6254.dpatch
1 #! /bin/sh /usr/share/dpatch/dpatch-run
2 ## CVE-2016-6254.dpatch by Florian Forster <octo@collectd.org>
3 ##
4 ## DP: network plugin: Fix heap overflow in parse_packet().
5 ## DP:
6 ## DP: Emilien Gaspar has identified a heap overflow in parse_packet(), the
7 ## DP: function used by the network plugin to parse incoming network packets.
8 ## DP:
9 ## DP: This is a vulnerability in collectd, though the scope is not clear at
10 ## DP: this point. At the very least specially crafted network packets can be
11 ## DP: used to crash the daemon. We can't rule out a potential remote code
12 ## DP: execution though.
13 ## DP:
14 ## DP: Fixes: CVE-2016-6254
15 ## DP:
16 ## DP: Upstream commit:
17 ## DP: https://github.com/collectd/collectd/commit/b589096
19 diff a/src/network.c b/src/network.c
20 --- a/src/network.c
21 +++ b/src/network.c
22 @@ -1392,6 +1392,7 @@
23                                 printed_ignore_warning = 1;
24                         }
25                         buffer = ((char *) buffer) + pkg_length;
26 +                       buffer_size -= (size_t) pkg_length;
27                         continue;
28                 }
29  #endif /* HAVE_LIBGCRYPT */
30 @@ -1419,6 +1420,7 @@
31                                 printed_ignore_warning = 1;
32                         }
33                         buffer = ((char *) buffer) + pkg_length;
34 +                       buffer_size -= (size_t) pkg_length;
35                         continue;
36                 }
37  #endif /* HAVE_LIBGCRYPT */
38 @@ -1560,6 +1562,7 @@
39                         DEBUG ("network plugin: parse_packet: Unknown part"
40                                         " type: 0x%04hx", pkg_type);
41                         buffer = ((char *) buffer) + pkg_length;
42 +                       buffer_size -= (size_t) pkg_length;
43                 }
44         } /* while (buffer_size > sizeof (part_header_t)) */
45