summaryrefslogtreecommitdiff
path: root/src/shared
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-29 14:29:31 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-30 19:42:35 +0100
commitc6cefd13eb55c8124a01e90021282f8610a05012 (patch)
treed1bc3022f1467030ffd53263a003ba726d817139 /src/shared
parent1dfbf0007af3023c2e3ae8282a0d0f229f3a89e3 (diff)
dns-domain: make sure dns_name_to_wire_format() may properly encode the root domain
The root domain consists of zero labels, and we should be able to encode that.
Diffstat (limited to 'src/shared')
-rw-r--r--src/shared/dns-domain.c10
1 files changed, 4 insertions, 6 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index ab61eb3b6e..ba6eff8f60 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -866,19 +866,17 @@ bool dns_name_is_single_label(const char *name) {
/* Encode a domain name according to RFC 1035 Section 3.1 */
int dns_name_to_wire_format(const char *domain, uint8_t *buffer, size_t len) {
- uint8_t *label_length;
- uint8_t *out;
+ uint8_t *label_length, *out;
int r;
- assert_return(buffer, -EINVAL);
- assert_return(domain, -EINVAL);
- assert_return(domain[0], -EINVAL);
+ assert(domain);
+ assert(buffer);
out = buffer;
do {
/* reserve a byte for label length */
- if (len == 0)
+ if (len <= 0)
return -ENOBUFS;
len--;
label_length = out;