File 0001-do-not-loop-but-syntax-error-on-a-malformed-unknown-R.diff of Package ldns

From 746d3fe3247543cf4e8aa2029704f016e0d246ff Mon Sep 17 00:00:00 2001
From: matje <matje@af62348d-a3ea-0310-b058-bb613a78d823>
Date: Wed, 20 Apr 2011 09:21:29 +0000
Subject: [PATCH] do not loop, but syntax error on a malformed unknown RR

git-svn-id: http://www.nlnetlabs.nl/svn/ldns/trunk@3483 af62348d-a3ea-0310-b058-bb613a78d823
---
 rr.c |   11 +++++++++++
 1 files changed, 11 insertions(+), 0 deletions(-)

Index: ldns-1.5.1/rr.c
===================================================================
--- ldns-1.5.1.orig/rr.c
+++ ldns-1.5.1/rr.c
@@ -419,6 +419,17 @@ ldns_rr_new_frm_str_internal(ldns_rr **n
 						cur_hex_data_size = 0;
 						while(cur_hex_data_size < 2 * hex_data_size) {
 							c = ldns_bget_token(rd_buf, rd, delimiters, LDNS_MAX_RDFLEN);
+							if (c == -1) {
+								LDNS_FREE(hex_data_str);
+								LDNS_FREE(rd);
+								LDNS_FREE(b64);
+								ldns_buffer_free(rd_buf);
+								ldns_buffer_free(rr_buf);
+								LDNS_FREE(rdata);
+								ldns_rr_free(new);
+								return LDNS_STATUS_SYNTAX_RDATA_ERR;
+							}
+ 							rd_strlen = strlen(rd);
 							rd_strlen = strlen(rd);
 							strncpy(hex_data_str + cur_hex_data_size, rd, rd_strlen);
 							cur_hex_data_size += rd_strlen;