diff options
author | Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> | 2019-03-09 08:40:57 +0000 |
---|---|---|
committer | Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> | 2019-07-25 12:23:46 +0100 |
commit | e9eec39aacde450ba87598d85987b374ce6aed95 (patch) | |
tree | 3823546edc4d7228951ea9e37f55f6fea3f06833 /package/network/services/dnsmasq/patches/0033-Fix-line-counting-when-reading-etc-hosts.patch | |
parent | 7d684b7673a7cb4f3fef366dd4f621f62fc4019c (diff) | |
download | upstream-e9eec39aacde450ba87598d85987b374ce6aed95.tar.gz upstream-e9eec39aacde450ba87598d85987b374ce6aed95.tar.bz2 upstream-e9eec39aacde450ba87598d85987b374ce6aed95.zip |
dnsmasq: backport latest patches
Backport upstream patches pre 2.81rc for testing purposes.
Let's see what falls out!
Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk>
Diffstat (limited to 'package/network/services/dnsmasq/patches/0033-Fix-line-counting-when-reading-etc-hosts.patch')
-rw-r--r-- | package/network/services/dnsmasq/patches/0033-Fix-line-counting-when-reading-etc-hosts.patch | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/package/network/services/dnsmasq/patches/0033-Fix-line-counting-when-reading-etc-hosts.patch b/package/network/services/dnsmasq/patches/0033-Fix-line-counting-when-reading-etc-hosts.patch new file mode 100644 index 0000000000..18b176837d --- /dev/null +++ b/package/network/services/dnsmasq/patches/0033-Fix-line-counting-when-reading-etc-hosts.patch @@ -0,0 +1,86 @@ +From 4219adeeef8a3d5447af4c9bd1e4e7c05b3112fd Mon Sep 17 00:00:00 2001 +From: Simon Kelley <simon@thekelleys.org.uk> +Date: Wed, 27 Feb 2019 20:30:21 +0000 +Subject: [PATCH 33/57] Fix line counting when reading /etc/hosts. + +Signed-off-by: Kevin Darbyshire-Bryant <ldir@darbyshire-bryant.me.uk> +--- + CHANGELOG | 4 ++++ + src/cache.c | 16 ++++++++-------- + 2 files changed, 12 insertions(+), 8 deletions(-) + +--- a/CHANGELOG ++++ b/CHANGELOG +@@ -17,6 +17,10 @@ version 2.81 + combinatorial explosion of compile-time options. Thanks to + Kevin Darbyshire-Bryant for the patch. + ++ Fix line-counting when reading /etc/hosts and friends; for ++ correct error messages. Thanks to Christian Rosentreter ++ for reporting this. ++ + + version 2.80 + Add support for RFC 4039 DHCP rapid commit. Thanks to Ashram Method +--- a/src/cache.c ++++ b/src/cache.c +@@ -1062,7 +1062,7 @@ static int eatspace(FILE *f) + } + + if (c == '\n') +- nl = 1; ++ nl++; + } + } + +@@ -1073,7 +1073,7 @@ static int gettok(FILE *f, char *token) + while (1) + { + if ((c = getc(f)) == EOF) +- return (count == 0) ? EOF : 1; ++ return (count == 0) ? -1 : 1; + + if (isspace(c) || c == '#') + { +@@ -1093,7 +1093,7 @@ int read_hostsfile(char *filename, unsig + { + FILE *f = fopen(filename, "r"); + char *token = daemon->namebuff, *domain_suffix = NULL; +- int addr_count = 0, name_count = cache_size, lineno = 0; ++ int addr_count = 0, name_count = cache_size, lineno = 1; + unsigned int flags = 0; + union all_addr addr; + int atnl, addrlen = 0; +@@ -1104,12 +1104,10 @@ int read_hostsfile(char *filename, unsig + return cache_size; + } + +- eatspace(f); ++ lineno += eatspace(f); + +- while ((atnl = gettok(f, token)) != EOF) ++ while ((atnl = gettok(f, token)) != -1) + { +- lineno++; +- + if (inet_pton(AF_INET, token, &addr) > 0) + { + flags = F_HOSTS | F_IMMORTAL | F_FORWARD | F_REVERSE | F_IPV4; +@@ -1145,7 +1143,7 @@ int read_hostsfile(char *filename, unsig + int fqdn, nomem; + char *canon; + +- if ((atnl = gettok(f, token)) == EOF) ++ if ((atnl = gettok(f, token)) == -1) + break; + + fqdn = !!strchr(token, '.'); +@@ -1178,6 +1176,8 @@ int read_hostsfile(char *filename, unsig + else if (!nomem) + my_syslog(LOG_ERR, _("bad name at %s line %d"), filename, lineno); + } ++ ++ lineno += atnl; + } + + fclose(f); |