From 85932ec5d89041424cf6d20c71b482e23cf17d2f Mon Sep 17 00:00:00 2001 From: "Antonio \"Criddi\" Mammita" <77116213+ammammita@users.noreply.github.com> Date: Wed, 13 Jan 2021 17:17:31 +0000 Subject: [PATCH] Ticket 18 and 19 (#22) Fix issue #18 and issue #19 Base template replacement issue --- rbldnsd.8 | 4 ++-- rbldnsd_util.c | 8 ++++++-- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/rbldnsd.8 b/rbldnsd.8 index 36e70fa..addb737 100644 --- a/rbldnsd.8 +++ b/rbldnsd.8 @@ -726,7 +726,7 @@ the above example may be simplified to: .fi There is no default TXT value, so .B rbldnsd -will not return anything for TXT queries it TXT isn't +will not return anything for TXT queries unless TXT isn't specified. .PP When A value is specified for a given entry, but TXT template @@ -782,7 +782,7 @@ text given for individual entries. In order to stop usage of base template \fB$=\fR for a single record, start it with \fB=\fR (which will be omitted from the resulting TXT value). For example, .nf - $0 See http://www.example.com/bl?$= ($) for details + $= See http://www.example.com/bl?$= ($) for details 127.0.0.2 r123 127.0.0.3 127.0.0.4 =See other blocklists for details about $ diff --git a/rbldnsd_util.c b/rbldnsd_util.c index c6d628d..eeafd07 100644 --- a/rbldnsd_util.c +++ b/rbldnsd_util.c @@ -243,6 +243,8 @@ int txtsubst(char sb[TXTBUFSIZ], const char *txt, char *const e = sb + 254; char *lp = sb; const char *s, *si, *sx; + const char *srec = s0; + if (txt[0] == '=') sx = ++txt; else if (sn[SUBST_BASE_TEMPLATE] && *sn[SUBST_BASE_TEMPLATE]) { @@ -273,8 +275,10 @@ int txtsubst(char sb[TXTBUFSIZ], const char *txt, sl = strlen(si); ++s; } - else - sl = strlen(si = s0); + else { + sl = strlen(si = srec); + } + if (lp + sl > e) /* silently truncate TXT RR >255 bytes */ sl = e - lp; memcpy(lp, si, sl);