From 79333a249888f930c51d88804a3484a1d5a54620 Mon Sep 17 00:00:00 2001 From: Giovanni Bajo Date: Sat, 28 Apr 2012 01:03:10 +0200 Subject: [PATCH] Fix a bug in extract_name_no_compression. When the maxlen was exactly equal to the length of the string, the function was returning 0 because the end-of-buffer check was misplaced. --- src/dnssec.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/dnssec.c b/src/dnssec.c index fe93036..8b4efaf 100644 --- a/src/dnssec.c +++ b/src/dnssec.c @@ -42,16 +42,16 @@ static int extract_name_no_compression(unsigned char *rr, int maxlen, char *buf) if (*buf >= 'A' && *buf <= 'Z') *buf += 'a' - 'A'; buf++; - } + } *buf++ = '.'; } // Remove trailing dot (if any) if (rr != start) *(--buf) = 0; - rr++; if (rr == end) return 0; - return rr-start; + // Trailing \0 in source data must be consumed + return rr-start+1; } /* Check whether today/now is between date_start and date_end */