From 3bdeed02505c9bbacb3b64a97ddcb1de967153b7 Mon Sep 17 00:00:00 2001 From: Willem Toorop Date: Thu, 27 Apr 2017 00:25:20 +0200 Subject: bugfix #1257: Free after reallocing to 0 size Thanks Stephan Zeisberg --- Changelog | 2 ++ str2host.c | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/Changelog b/Changelog index 77861485..d7aa7116 100644 --- a/Changelog +++ b/Changelog @@ -1,4 +1,6 @@ 1.7.1 ????-??-?? + * bugfix #1257: Free after reallocing to 0 size + Thanks Stephan Zeisberg * bugfix #1256: Check parse limit before t increment Thanks Stephan Zeisberg * bugfix #1245: Only one signature per RRset needs to be valid with diff --git a/str2host.c b/str2host.c index b274b17a..f2a317be 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) { -- cgit v1.2.1