Skip to content

Commit a0186fd

Browse files
authored
Merge pull request #2693 from pi-hole/development
Pi-hole FTL v6.3.3
2 parents bc5e8b2 + 75c53eb commit a0186fd

File tree

6 files changed

+46
-11
lines changed

6 files changed

+46
-11
lines changed

.github/workflows/codeql.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ jobs:
8585
8686
# Initializes the CodeQL tools for scanning.
8787
- name: Initialize CodeQL
88-
uses: github/codeql-action/init@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
88+
uses: github/codeql-action/init@0499de31b99561a6d14a36a5f662c2a54f91beee #v4.31.2
8989
with:
9090
languages: ${{ matrix.language }}
9191
build-mode: ${{ matrix.build-mode }}
@@ -108,7 +108,7 @@ jobs:
108108
./build.sh
109109
110110
- name: Perform CodeQL Analysis
111-
uses: github/codeql-action/analyze@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
111+
uses: github/codeql-action/analyze@0499de31b99561a6d14a36a5f662c2a54f91beee #v4.31.2
112112
with:
113113
category: "/language:${{matrix.language}}"
114114
upload: failure-only # upload only in case of failure, otherwise upload later after filtering
@@ -134,7 +134,7 @@ jobs:
134134
output: codeql-results/cpp.sarif
135135

136136
- name: Upload SARIF
137-
uses: github/codeql-action/upload-sarif@4e94bd11f71e507f7f87df81788dff88d1dacbfb #v4.31.0
137+
uses: github/codeql-action/upload-sarif@0499de31b99561a6d14a36a5f662c2a54f91beee #v4.31.2
138138
with:
139139
sarif_file: codeql-results/cpp.sarif
140140

src/api/docs/content/specs/lists.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ components:
4646
- "List management"
4747
operationId: "replace_lists"
4848
description: |
49-
Items may be updated by replacing them. `{list}` is required.
49+
Items may be updated by replacing them. `{list}` and `{listtype}` are required.
5050
5151
Ensure to send all the required parameters (such as `comment`) to ensure these properties are retained.
5252
The read-only fields `id` and `date_added` are preserved, `date_modified` is automatically updated on success.
@@ -96,6 +96,7 @@ components:
9696
- "List management"
9797
operationId: "delete_lists"
9898
description: |
99+
`{list}` and `{listtype}` are required.
99100
*Note:* There will be no content on success.
100101
responses:
101102
'204':

src/config/config.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -897,7 +897,7 @@ void initConfig(struct config *conf)
897897
conf->ntp.sync.server.a = cJSON_CreateStringReference("A valid NTP upstream server");
898898
conf->ntp.sync.server.t = CONF_STRING;
899899
conf->ntp.sync.server.d.s = (char*)"pool.ntp.org";
900-
conf->ntp.sync.server.c = validate_stub; // Only type-based checking
900+
conf->ntp.sync.server.c = validate_dns_domain_or_ip;
901901

902902
conf->ntp.sync.interval.k = "ntp.sync.interval";
903903
conf->ntp.sync.interval.h = "Interval in seconds between successive synchronization attempts with the NTP server";

src/config/validator.c

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -676,3 +676,26 @@ void sanitize_dns_hosts(union conf_value *val)
676676
free(str);
677677
}
678678
}
679+
680+
// Validate a single domain or IP address
681+
bool validate_dns_domain_or_ip(union conf_value *val, const char *key, char err[VALIDATOR_ERRBUF_LEN])
682+
{
683+
// Check if it's a valid domain
684+
if(valid_domain(val->s, strlen(val->s), false))
685+
{
686+
return true;
687+
}
688+
689+
// Check if IP is valid
690+
struct in_addr addr;
691+
struct in6_addr addr6;
692+
int ip4 = 0, ip6 = 0;
693+
if((ip4 = inet_pton(AF_INET, val->s, &addr) == 1) || (ip6 = inet_pton(AF_INET6, val->s, &addr6)) == 1)
694+
{
695+
return true;
696+
}
697+
698+
// If neither, return an error
699+
snprintf(err, VALIDATOR_ERRBUF_LEN, "%s: neither a valid domain nor IP address", key);
700+
return false;
701+
}

src/config/validator.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,5 +28,6 @@ bool validate_regex_array(union conf_value *val, const char *key, char err[VALID
2828
bool validate_dns_revServers(union conf_value *val, const char *key, char err[VALIDATOR_ERRBUF_LEN]);
2929
bool validate_ui_min_7_or_0(union conf_value *val, const char *key, char err[VALIDATOR_ERRBUF_LEN]);
3030
void sanitize_dns_hosts(union conf_value *val);
31+
bool validate_dns_domain_or_ip(union conf_value *val, const char *key, char err[VALIDATOR_ERRBUF_LEN]);
3132

3233
#endif // CONFIG_VALIDATOR_H

src/ntp/client.c

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,8 @@ bool ntp_client(const char *server, const bool settime, const bool print)
494494
}
495495
errbuf[sizeof(errbuf) - 1] = '\0';
496496
log_ntp_message(true, false, errbuf);
497-
freeaddrinfo(saddr);
497+
if(saddr != NULL)
498+
freeaddrinfo(saddr);
498499
return false;
499500
}
500501

@@ -503,7 +504,8 @@ bool ntp_client(const char *server, const bool settime, const bool print)
503504
if(ntp == NULL)
504505
{
505506
log_err("Cannot allocate memory for NTP client");
506-
freeaddrinfo(saddr);
507+
if(saddr != NULL)
508+
freeaddrinfo(saddr);
507509
return false;
508510
}
509511

@@ -520,7 +522,8 @@ bool ntp_client(const char *server, const bool settime, const bool print)
520522
{
521523
close(s);
522524
free(ntp);
523-
freeaddrinfo(saddr);
525+
if(saddr != NULL)
526+
freeaddrinfo(saddr);
524527
return false;
525528
}
526529
// Get reply
@@ -543,7 +546,8 @@ bool ntp_client(const char *server, const bool settime, const bool print)
543546
printf("\n");
544547

545548
// Free allocated memory
546-
freeaddrinfo(saddr);
549+
if(saddr != NULL)
550+
freeaddrinfo(saddr);
547551
saddr = NULL;
548552

549553
// Compute average and standard deviation
@@ -764,9 +768,15 @@ bool ntp_start_sync_thread(pthread_attr_t *attr)
764768
}
765769
// Return early if a clock disciplining NTP client is detected
766770
// Checks chrony, the ntp family (ntp, ntpsec and openntpd), and ntpd-rs
767-
if(search_proc("chronyd") > 0 || search_proc("ntpd") > 0 || search_proc("ntp-daemon") > 0)
771+
const int chronyd_found = search_proc("chronyd");
772+
const int ntpd_found = search_proc("ntpd");
773+
const int ntp_daemon_found = search_proc("ntp-daemon");
774+
if(chronyd_found > 0 || ntpd_found > 0 || ntp_daemon_found > 0)
768775
{
769-
log_info("Clock disciplining NTP client detected, not starting embedded NTP client/server");
776+
log_info("Clock disciplining NTP client detected ( %s%s%s), not starting embedded NTP client/server",
777+
chronyd_found > 0 ? "chronyd " : "",
778+
ntpd_found > 0 ? "ntpd " : "",
779+
ntp_daemon_found > 0 ? "ntp-daemon " : "");
770780
return false;
771781
}
772782

0 commit comments

Comments
 (0)