rpz triggers, use tld name for tld pointer in suffix removal.
@@ -668,11 +668,17 @@ static int
rpz_strip_nsdname_suffix(uint8_t* dname, size_t maxdnamelen,
uint8_t** stripdname, size_t* stripdnamelen)
{
- uint8_t* stripped = get_tld_label(dname, maxdnamelen);
+ uint8_t* tldstart = get_tld_label(dname, maxdnamelen);
uint8_t swap;
- if(stripped == NULL) {
+ if(tldstart == NULL) {
+ if(dname == NULL) {
+ *stripdname = NULL;
+ *stripdnamelen = 0;
+ return 0;
+ }
*stripdname = memdup(dname, maxdnamelen);
if(!*stripdname) {
+ *stripdnamelen = 0;
log_err("malloc failure for rpz strip suffix");
return 0;
}
@@ -681,11 +687,11 @@ rpz_strip_nsdname_suffix(uint8_t* dname, size_t maxdnamelen,
}
/* shorten the domain name briefly,
* then we allocate a new name with the correct length */
- swap = *stripped;
- *stripped = 0;
+ swap = *tldstart;
+ *tldstart = 0;
(void)dname_count_size_labels(dname, stripdnamelen);
*stripdname = memdup(dname, *stripdnamelen);
- *stripped = swap;
+ *tldstart = swap;
if(!*stripdname) {
*stripdnamelen = 0;
log_err("malloc failure for rpz strip suffix");
@@ -701,12 +707,14 @@ rpz_insert_nsdname_trigger(struct rpz* r, uint8_t* dname, size_t dnamelen,
{
uint8_t* dname_stripped = NULL;
size_t dnamelen_stripped = 0;
- verbose(VERB_ALGO, "rpz: insert nsdname trigger: %s", rpz_action_to_string(a));
+ verbose(VERB_ALGO, "rpz: insert nsdname trigger: %s",
+ rpz_action_to_string(a));
rpz_log_dname("insert nsdname trigger", dname, dnamelen);
rpz_strip_nsdname_suffix(dname, dnamelen, &dname_stripped,
&dnamelen_stripped);
- rpz_log_dname("insert nsdname trigger (stripped)", dname_stripped, dnamelen_stripped);
+ rpz_log_dname("insert nsdname trigger (stripped)", dname_stripped,
+ dnamelen_stripped);
if(a == RPZ_INVALID_ACTION) {
verbose(VERB_ALGO, "rpz: skipping invalid action");
