An ersatz vector is now replaced.

This commit is contained in:
2025-08-03 21:09:47 -04:00
parent d5b9cb2c5e
commit 331f1c030b

View File

@ -9,19 +9,19 @@
#include <stdlib.h>
#include <vector>
#include "../dlib/dlib.h"
#include "msg.hh"
#include "list.h"
#include "domain.hh"
typedef struct {
struct Rule {
char *origin;
char *destination;
} Rule;
};
static Rule *exceptions = NULL;
static int num_exceptions = 0;
static int num_exceptions_max = 1;
std::vector< Rule > exceptions;
static bool_t default_deny = FALSE;
@ -64,10 +64,9 @@ void a_Domain_parse(FILE *fp)
MSG("Domain: Default action \"%s\" not recognised.\n", tok2);
}
} else {
a_List_add(exceptions, num_exceptions, num_exceptions_max, Rule);
exceptions[num_exceptions].origin = dStrdup(tok1);
exceptions[num_exceptions].destination = dStrdup(tok2);
num_exceptions++;
exceptions.emplace_back();
exceptions.back().origin = dStrdup(tok1);
exceptions.back().destination = dStrdup(tok2);
_MSG("Domain: Exception from %s to %s.\n", tok1, tok2);
}
}
@ -80,11 +79,11 @@ void a_Domain_freeall(void)
{
int i = 0;
for (i = 0; i < num_exceptions; i++) {
for (i = 0; i < exceptions.size(); i++) {
dFree(exceptions[i].origin);
dFree(exceptions[i].destination);
}
dFree(exceptions);
exceptions.clear();
}
/**
@ -119,7 +118,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
bool_t ret;
const char *source_host, *dest_host;
if (default_deny == FALSE && num_exceptions == 0)
if (default_deny == FALSE && exceptions.size() == 0)
return TRUE;
source_host = URL_HOST(source);
@ -138,7 +137,7 @@ bool_t a_Domain_permit(const DilloUrl *source, const DilloUrl *dest)
ret = default_deny ? FALSE : TRUE;
for (i = 0; i < num_exceptions; i++) {
for (i = 0; i < exceptions.size(); i++) {
if (Domain_match(source_host, exceptions[i].origin) &&
Domain_match(dest_host, exceptions[i].destination)) {
ret = default_deny;