Static analysis improvements

Signed-off-by: DL6ER <dl6er@dl6er.de>
This commit is contained in:
DL6ER
2021-11-03 16:14:31 +01:00
parent 285d62a4df
commit 7dbe1a09eb
7 changed files with 13 additions and 14 deletions
+1
View File
@@ -211,6 +211,7 @@ static int read_temp_sensor(struct ftl_conn *api,
cJSON *item = JSON_NEW_OBJ();
if(f_label != NULL && fread(label, sizeof(label)-1, 1, f_label) > 0)
{
label[sizeof(label)-1] = '\0';
JSON_OBJ_COPY_STR(item, "name", label);
}
else
+2 -2
View File
@@ -117,13 +117,13 @@ bool readFTLtoml(void)
toml_table_t *specialDomains = toml_table_in(dns, "specialDomains");
if(specialDomains)
{
toml_datum_t mozillaCanary = toml_bool_in(dns, "mozillaCanary");
toml_datum_t mozillaCanary = toml_bool_in(specialDomains, "mozillaCanary");
if(mozillaCanary.ok)
config.special_domains.mozilla_canary = mozillaCanary.u.b;
else
log_debug(DEBUG_CONFIG, "dns.specialDomains.mozillaCanary DOES NOT EXIST");
toml_datum_t blockICloudPR = toml_bool_in(dns, "blockICloudPR");
toml_datum_t blockICloudPR = toml_bool_in(specialDomains, "blockICloudPR");
if(blockICloudPR.ok)
config.special_domains.mozilla_canary = blockICloudPR.u.b;
else
+2 -5
View File
@@ -50,7 +50,7 @@ static sqlite3_stmt* auditlist_stmt = NULL;
bool gravityDB_opened = false;
// Table names corresponding to the enum defined in gravity-db.h
static const char* tablename[] = { "vw_gravity", "vw_blacklist", "vw_whitelist", "vw_regex_blacklist", "vw_regex_whitelist" , "" };
static const char* tablename[] = { "vw_gravity", "vw_blacklist", "vw_whitelist", "vw_regex_blacklist", "vw_regex_whitelist" , "client", "group", "adlist", "denied_domains", "allowed_domains", "" };
// Prototypes from functions in dnsmasq's source
extern void rehash(int size);
@@ -900,10 +900,7 @@ static inline void gravityDB_finalize_client_statements(clientsData *client)
// Unset group found property to trigger a check next time the
// client sends a query
if(client != NULL)
{
client->flags.found_group = false;
}
client->flags.found_group = false;
}
// Close gravity database connection
+1 -1
View File
@@ -87,7 +87,7 @@ static struct {
char name[IFNAMSIZ];
union all_addr addr4;
union all_addr addr6;
} next_iface = {false, false, "", {{0}}, {{0}}};
} next_iface = {false, false, "", {{ 0 }}, {{ 0 }}};
// Fork-private copy of the server data the most recent reply came from
static union mysockaddr last_server = {{ 0 }};
+5 -4
View File
@@ -54,14 +54,15 @@ void FTL_parse_pseudoheaders(struct dns_header *header, size_t n, union mysockad
// Debug logging
if(config.debug & DEBUG_EDNS0)
{
char payload[5*plen+1];
char payload[3*plen+1];
memset(payload, 0, sizeof(payload));
for(unsigned int i = 0; i < plen; i++)
sprintf(&payload[5*i], "0x%02x ", pheader[i]);
log_debug(DEBUG_EDNS0, "EDNS(0) pheader = %s (%lu bytes)", payload, plen);
sprintf(&payload[3*i], "%02X ", pheader[i]);
log_debug(DEBUG_EDNS0, "EDNS(0) pheader: %s (%lu bytes)",
payload, (long unsigned int)plen);
}
// Working pointer
// Working pointer
unsigned char *p = pheader;
// RFC 6891 EDNS(0) Extensions 6.1.2. Wire Format
+1 -1
View File
@@ -24,7 +24,7 @@ void add_to_dnsmasq_log_fifo_buffer(const char *payload, const size_t length)
{
// Log is full, move everything one slot forward to make space for a new record at the end
// This pruges the oldest message from the list (it is overwritten by the second message)
memmove(fifo_log->message[0], fifo_log->message[1], (LOG_SIZE - 1u) * MAX_MESSAGE);
memmove(&fifo_log->message[0][0], &fifo_log->message[1][0], (LOG_SIZE - 1u) * MAX_MESSAGE);
memmove(&fifo_log->timestamp[0], &fifo_log->timestamp[1], (LOG_SIZE - 1u) * sizeof(fifo_log->timestamp[0]));
idx = LOG_SIZE - 1u;
}
+1 -1
View File
@@ -65,7 +65,7 @@ typedef struct {
int denied;
} domains;
} database;
int querytype[TYPE_MAX-1];
int querytype[TYPE_MAX];
int status[QUERY_STATUS_MAX];
int reply[QUERY_REPLY_MAX];
} countersStruct;