From 6197b6bb1690d6d405fc08fc86523e2ecfc3fcaa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Men=C5=A1=C3=ADk?= Date: Thu, 9 Nov 2017 17:47:33 +0100 Subject: [PATCH] Fix memory corruption in ldns_str2rdf_long_str (#1511046) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Petr Menšík --- ldns-1.7.0-realloc.patch | 30 ++++++++++++++++++++++++++++++ ldns.spec | 7 ++++++- 2 files changed, 36 insertions(+), 1 deletion(-) create mode 100644 ldns-1.7.0-realloc.patch diff --git a/ldns-1.7.0-realloc.patch b/ldns-1.7.0-realloc.patch new file mode 100644 index 0000000..25be44d --- /dev/null +++ b/ldns-1.7.0-realloc.patch @@ -0,0 +1,30 @@ +From 3bdeed02505c9bbacb3b64a97ddcb1de967153b7 Mon Sep 17 00:00:00 2001 +From: Willem Toorop +Date: Thu, 27 Apr 2017 00:25:20 +0200 +Subject: [PATCH] bugfix #1257: Free after reallocing to 0 size + +Thanks Stephan Zeisberg +--- + str2host.c | 6 ++++-- + 1 file changed, 4 insertions(+), 2 deletions(-) + +diff --git a/str2host.c b/str2host.c +index b274b17..f2a317b 100644 +--- a/str2host.c ++++ b/str2host.c +@@ -1525,8 +1525,10 @@ ldns_str2rdf_long_str(ldns_rdf **rd, const char *str) + if (! str) { + return LDNS_STATUS_SYNTAX_BAD_ESCAPE; + } +- length = (size_t)(dp - data); +- ++ if (!(length = (size_t)(dp - data))) { ++ LDNS_FREE(data); ++ return LDNS_STATUS_SYNTAX_EMPTY; ++ } + /* Lose the overmeasure */ + data = LDNS_XREALLOC(dp = data, uint8_t, length); + if (! data) { +-- +2.9.5 + diff --git a/ldns.spec b/ldns.spec index 169d9b7..668a213 100644 --- a/ldns.spec +++ b/ldns.spec @@ -26,13 +26,14 @@ Summary: Low-level DNS(SEC) library with API Name: ldns Version: 1.7.0 -Release: 9%{?dist} +Release: 10%{?dist} License: BSD Url: http://www.nlnetlabs.nl/%{name}/ Source0: http://www.nlnetlabs.nl/downloads/%{name}/%{name}-%{version}.tar.gz Patch1: ldns-1.7.0-multilib.patch Patch2: ldns-1.7.0-parse-limit.patch +Patch3: ldns-1.7.0-realloc.patch Group: System Environment/Libraries # Only needed for builds from svn snapshot @@ -116,6 +117,7 @@ This package contains documentation for the ldns library %setup -q %patch1 -p1 %patch2 -p1 -b .limit +%patch3 -p1 -b .realloc # To built svn snapshots # rm config.guess config.sub ltmain.sh # aclocal @@ -274,6 +276,9 @@ rm -rf %{buildroot} %doc doc %changelog +* Thu Nov 09 2017 Petr Menšík - 1.7.0-10 +- Fix memory corruption in ldns_str2rdf_long_str (#1511046) + * Thu Nov 09 2017 Petr Menšík - 1.7.0-9 - Fix memory corruption in ldns_rr_new_frm_fp_l (#1511046)