From 32aa5e9b60d7fbdcf2f91a8881cc2315d0eeb127 Mon Sep 17 00:00:00 2001 From: Remi Gacogne Date: Mon, 27 May 2019 16:28:58 +0200 Subject: [PATCH] rec: Support a nullptr 'name' in pdns_ffi_param_add_record() --- pdns/lua-recursor4-ffi.hh | 3 +++ pdns/lua-recursor4.cc | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pdns/lua-recursor4-ffi.hh b/pdns/lua-recursor4-ffi.hh index a6e82ccab4..817fe1259f 100644 --- a/pdns/lua-recursor4-ffi.hh +++ b/pdns/lua-recursor4-ffi.hh @@ -63,5 +63,8 @@ extern "C" { void pdns_ffi_param_set_log_query(pdns_ffi_param_t* ref, bool logQuery) __attribute__ ((visibility ("default"))); void pdns_ffi_param_set_rcode(pdns_ffi_param_t* ref, int rcode) __attribute__ ((visibility ("default"))); void pdns_ffi_param_set_follow_cname_records(pdns_ffi_param_t* ref, bool follow) __attribute__ ((visibility ("default"))); + + /* returns true if the record was correctly added, false if something went wrong. + Passing a NULL pointer to 'name' will result in the qname being used for the record owner name. */ bool pdns_ffi_param_add_record(pdns_ffi_param_t *ref, const char* name, uint16_t type, uint32_t ttl, const char* content, size_t contentSize, pdns_record_place_t place) __attribute__ ((visibility ("default"))); } diff --git a/pdns/lua-recursor4.cc b/pdns/lua-recursor4.cc index ead175a375..6178ee72d6 100644 --- a/pdns/lua-recursor4.cc +++ b/pdns/lua-recursor4.cc @@ -866,7 +866,7 @@ bool pdns_ffi_param_add_record(pdns_ffi_param_t *ref, const char* name, uint16_t { try { DNSRecord dr; - dr.d_name = DNSName(name); + dr.d_name = name != nullptr ? DNSName(name) : ref->qname; dr.d_ttl = ttl; dr.d_type = type; dr.d_class = QClass::IN; -- 2.47.2