From: Wouter Wijngaards Date: Mon, 9 Aug 2010 13:55:25 +0000 (+0000) Subject: Justin item 4: check salt bounds. X-Git-Tag: release-1.6.7~66 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=bb55b92d323f01730e317deeea0cc0b9576edb6b;p=thirdparty%2Fldns.git Justin item 4: check salt bounds. --- diff --git a/host2str.c b/host2str.c index c7df116f..402212a0 100644 --- a/host2str.c +++ b/host2str.c @@ -752,18 +752,14 @@ ldns_rdf2buffer_str_nsec3_salt(ldns_buffer *output, const ldns_rdf *rdf) uint8_t salt_pos; uint8_t *data = ldns_rdf_data(rdf); - size_t pos; salt_length = data[0]; - /* todo: length check needed/possible? */ /* from now there are variable length entries so remember pos */ - pos = 1; - if (salt_length == 0) { + if (salt_length == 0 || ((size_t)salt_length)+1 > ldns_rdf_size(rdf)) { ldns_buffer_printf(output, "- "); } else { for (salt_pos = 0; salt_pos < salt_length; salt_pos++) { ldns_buffer_printf(output, "%02x", data[1 + salt_pos]); - pos++; } ldns_buffer_printf(output, " "); }