summaryrefslogtreecommitdiff
path: root/src/shared/dns-domain.c
diff options
context:
space:
mode:
authorTom Gundersen <teg@jklm.no>2015-12-20 01:35:44 +0000
committerTom Gundersen <teg@jklm.no>2015-12-20 01:35:44 +0000
commitd73fe9134fcabe69e2984691e998e259d26d064b (patch)
treecea21a40a678c2902aa25836240038bc16e026ed /src/shared/dns-domain.c
parent0038f71da9db5eb163c9ca7885189e53c7416f9a (diff)
parent6773896e850e498278e460f4fb57b8a214572f9c (diff)
Merge pull request #2190 from poettering/dnssec6
Add DNSSEC proof of unsignedness and NSEC3 proof
Diffstat (limited to 'src/shared/dns-domain.c')
-rw-r--r--src/shared/dns-domain.c16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index 0466857042..c46f7d21b7 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -48,7 +48,6 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
assert(name);
assert(*name);
- assert(dest);
n = *name;
d = dest;
@@ -79,9 +78,12 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
else if (*n == '\\' || *n == '.') {
/* Escaped backslash or dot */
- *(d++) = *(n++);
+
+ if (d)
+ *(d++) = *n;
sz--;
r++;
+ n++;
} else if (n[0] >= '0' && n[0] <= '9') {
unsigned k;
@@ -100,7 +102,8 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
if (k < ' ' || k > 255 || k == 127)
return -EINVAL;
- *(d++) = (char) k;
+ if (d)
+ *(d++) = (char) k;
sz--;
r++;
@@ -111,9 +114,12 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
} else if ((uint8_t) *n >= (uint8_t) ' ' && *n != 127) {
/* Normal character */
- *(d++) = *(n++);
+
+ if (d)
+ *(d++) = *n;
sz--;
r++;
+ n++;
} else
return -EINVAL;
}
@@ -122,7 +128,7 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
if (r == 0 && *n)
return -EINVAL;
- if (sz >= 1)
+ if (sz >= 1 && d)
*d = 0;
*name = n;