commit 3d63887: [Minor] Add experimental support of CNAME RR type

Vsevolod Stakhov vsevolod at rspamd.com
Wed Aug 10 22:42:03 UTC 2022


Author: Vsevolod Stakhov
Date: 2022-08-10 23:35:28 +0100
URL: https://github.com/rspamd/rspamd/commit/3d6388791666c5f13524cce3f428b875bbdaa345 (HEAD -> master)

[Minor] Add experimental support of CNAME RR type

---
 contrib/librdns/parse.c | 9 ++++++---
 contrib/librdns/rdns.h  | 4 ++++
 contrib/librdns/util.c  | 3 +++
 3 files changed, 13 insertions(+), 3 deletions(-)

diff --git a/contrib/librdns/parse.c b/contrib/librdns/parse.c
index e9fb85e98..f9025e159 100644
--- a/contrib/librdns/parse.c
+++ b/contrib/librdns/parse.c
@@ -438,9 +438,12 @@ rdns_parse_rr (struct rdns_resolver *resolver,
 		parsed = true;
 		break;
 	case DNS_T_CNAME:
-		/* Skip cname records */
-		p += datalen;
-		*remain -= datalen;
+		if (! rdns_parse_labels (resolver, in, &elt->content.cname.name, &p,
+				rep, remain, true)) {
+			rdns_info ("invalid labels in CNAME record; domain %s", rep->requested_name);
+			return -1;
+		}
+		parsed = true;
 		break;
 	default:
 		rdns_info ("unexpected RR type: %d; domain %s", type, rep->requested_name);
diff --git a/contrib/librdns/rdns.h b/contrib/librdns/rdns.h
index 2e00951ea..c0da5ed29 100644
--- a/contrib/librdns/rdns.h
+++ b/contrib/librdns/rdns.h
@@ -48,6 +48,7 @@ enum rdns_request_type {
 	RDNS_REQUEST_INVALID = -1,
 	RDNS_REQUEST_A = 1,
 	RDNS_REQUEST_NS = 2,
+	RDNS_REQUEST_CNAME = 5,
 	RDNS_REQUEST_SOA = 6,
 	RDNS_REQUEST_PTR = 12,
 	RDNS_REQUEST_MX = 15,
@@ -101,6 +102,9 @@ union rdns_reply_element_un {
 		uint16_t datalen;
 		uint8_t *data;
 	} tlsa;
+	struct {
+		char *name;
+	} cname;
 };
 
 struct rdns_reply_entry {
diff --git a/contrib/librdns/util.c b/contrib/librdns/util.c
index e09eb2007..b20b327bc 100644
--- a/contrib/librdns/util.c
+++ b/contrib/librdns/util.c
@@ -457,6 +457,9 @@ rdns_reply_free (struct rdns_reply *rep)
 				free (entry->content.soa.mname);
 				free (entry->content.soa.admin);
 				break;
+			case RDNS_REQUEST_CNAME:
+				free(entry->content.cname.name);
+				break;
 			default:
 				break;
 			}


More information about the Commits mailing list