From a06fa348e7fcbebb36f13b04aa9e7ad5166d1c53 Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Mon, 21 Feb 2011 06:43:23 +0000 Subject: [PATCH] 3030. [bug] dns_rdatatype_format() handle a zero sized buffer. [RT #22521] --- CHANGES | 3 +++ lib/dns/rdata.c | 11 ++++++----- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/CHANGES b/CHANGES index aa3bf0d03b..5ae52166ca 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,6 @@ +3030. [bug] dns_rdatatype_format() handle a zero sized buffer. + [RT #22521] + 3029. [bug] isc_netaddr_format() handle a zero sized buffer. [RT #22521] diff --git a/lib/dns/rdata.c b/lib/dns/rdata.c index f61d9e87cf..64fc40e13e 100644 --- a/lib/dns/rdata.c +++ b/lib/dns/rdata.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: rdata.c,v 1.209 2011/01/13 04:59:25 tbox Exp $ */ +/* $Id: rdata.c,v 1.209.8.1 2011/02/21 06:43:23 marka Exp $ */ /*! \file */ @@ -963,6 +963,9 @@ dns_rdatatype_format(dns_rdatatype_t rdtype, isc_result_t result; isc_buffer_t buf; + if (size == 0U) + return; + isc_buffer_init(&buf, array, size); result = dns_rdatatype_totext(rdtype, &buf); /* @@ -974,10 +977,8 @@ dns_rdatatype_format(dns_rdatatype_t rdtype, else result = ISC_R_NOSPACE; } - if (result != ISC_R_SUCCESS) { - snprintf(array, size, ""); - array[size - 1] = '\0'; - } + if (result != ISC_R_SUCCESS) + strlcpy(array, "", size); } /*