--------
- daemon/http: improved URI checks to fix some proxies (#746, !1311)
- daemon/tls: fixed a double-free for some cases of policy.TLS_FORWARD (!1314)
+- hints module: improve parsing comments in hosts files (!1315)
Knot Resolver 5.5.1 (2022-06-14)
/* Load file to map */
struct hints_data *data = module->data;
- size_t line_len = 0;
+ size_t line_len_unused = 0;
size_t count = 0;
size_t line_count = 0;
auto_free char *line = NULL;
int ret = kr_ok();
- while (getline(&line, &line_len, fp) > 0) {
+ while (getline(&line, &line_len_unused, fp) > 0) {
++line_count;
+ /* Ingore #comments as described in man hosts.5 */
+ char *comm = strchr(line, '#');
+ if (comm) {
+ *comm = '\0';
+ }
+
char *saveptr = NULL;
const char *addr = strtok_r(line, " \t\n", &saveptr);
- if (addr == NULL || strchr(addr, '#') || strlen(addr) == 0) {
+ if (addr == NULL || strlen(addr) == 0) {
continue;
}
const char *canonical_name = strtok_r(NULL, " \t\n", &saveptr);