summaryrefslogtreecommitdiff
path: root/src/shared/dns-domain.c
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-12-26 12:43:28 +0100
committerLennart Poettering <lennart@poettering.net>2015-12-27 01:41:39 +0100
commit5651285934ade033c0662afbbee940855f6bd2fb (patch)
treed75ba475e940e478eabb5d25a63f57e6ef47c235 /src/shared/dns-domain.c
parent735323d9d3cddcd08247e541ccfdd8285c87c701 (diff)
shared: fix handling of suffix "." in dns_name_compare_func()
All our other domain name handling functions make no destinction between domain names that end in a dot plus a NUL, or those just ending in a NUL. Make sure dns_name_compare_func() and dns_label_unescape_suffix() do the same.
Diffstat (limited to 'src/shared/dns-domain.c')
-rw-r--r--src/shared/dns-domain.c18
1 files changed, 11 insertions, 7 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index 159944858d..0273b9e3c9 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -154,20 +154,24 @@ int dns_label_unescape_suffix(const char *name, const char **label_terminal, cha
return 0;
}
- assert(**label_terminal == '.' || **label_terminal == 0);
+ terminal = *label_terminal;
+ assert(*terminal == '.' || *terminal == 0);
- /* skip current terminal character */
- terminal = *label_terminal - 1;
+ /* Skip current terminal character (and accept domain names ending it ".") */
+ if (*terminal == 0)
+ terminal--;
+ if (terminal >= name && *terminal == '.')
+ terminal--;
- /* point name to the last label, and terminal to the preceding terminal symbol (or make it a NULL pointer) */
+ /* Point name to the last label, and terminal to the preceding terminal symbol (or make it a NULL pointer) */
for (;;) {
if (terminal < name) {
- /* reached the first label, so indicate that there are no more */
+ /* Reached the first label, so indicate that there are no more */
terminal = NULL;
break;
}
- /* find the start of the last label */
+ /* Find the start of the last label */
if (*terminal == '.') {
const char *y;
unsigned slashes = 0;
@@ -176,7 +180,7 @@ int dns_label_unescape_suffix(const char *name, const char **label_terminal, cha
slashes ++;
if (slashes % 2 == 0) {
- /* the '.' was not escaped */
+ /* The '.' was not escaped */
name = terminal + 1;
break;
} else {