From 77397daf05511dc737eeec159badc05f11bfaddd Mon Sep 17 00:00:00 2001 From: Mark Andrews Date: Tue, 15 May 2007 01:54:49 +0000 Subject: [PATCH] 2177. [bug] Array bounds overrun on read (rcodetext). [RT #16798] --- CHANGES | 2 ++ lib/dns/message.c | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/CHANGES b/CHANGES index c580afa630..0fa2785d10 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,5 @@ +2177. [bug] Array bounds overrun on read (rcodetext). [RT #16798] + 2176. [contrib] dbus update to handle race condition during initialisation (Bugzilla 235809). [RT #16842] diff --git a/lib/dns/message.c b/lib/dns/message.c index bbfeb3fedb..fead9905ea 100644 --- a/lib/dns/message.c +++ b/lib/dns/message.c @@ -15,7 +15,7 @@ * PERFORMANCE OF THIS SOFTWARE. */ -/* $Id: message.c,v 1.233 2006/12/04 01:52:46 marka Exp $ */ +/* $Id: message.c,v 1.234 2007/05/15 01:54:49 marka Exp $ */ /*! \file */ @@ -3064,8 +3064,7 @@ dns_message_sectiontotext(dns_message_t *msg, dns_section_t section, ADD_STRING(target, ";; "); if (msg->opcode != dns_opcode_update) { ADD_STRING(target, sectiontext[section]); - } - else { + } else { ADD_STRING(target, updsectiontext[section]); } ADD_STRING(target, " SECTION:\n"); @@ -3187,7 +3186,12 @@ dns_message_totext(dns_message_t *msg, const dns_master_style_t *style, ADD_STRING(target, ";; ->>HEADER<<- opcode: "); ADD_STRING(target, opcodetext[msg->opcode]); ADD_STRING(target, ", status: "); - ADD_STRING(target, rcodetext[msg->rcode]); + if (msg->rcode < (sizeof(rcodetext)/sizeof(rcodetext[0]))) { + ADD_STRING(target, rcodetext[msg->rcode]); + } else { + snprintf(buf, sizeof(buf), "%4u", msg->rcode); + ADD_STRING(target, buf); + } ADD_STRING(target, ", id: "); snprintf(buf, sizeof(buf), "%6u", msg->id); ADD_STRING(target, buf);