summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLennart Poettering <lennart@poettering.net>2015-11-30 19:40:20 +0100
committerLennart Poettering <lennart@poettering.net>2015-11-30 19:42:35 +0100
commit37ade1283745f39e3fa37aa2603809fb2daf067c (patch)
tree203d88cf9e867abe212ae9ac6020a444022eab86 /src
parent50dee79bfbe0782a342ef864b28d7d6613c0b1fb (diff)
dns-domain: change error codes when dealing with too short buffers to ENOBUFS
Some calls used ENOBUFS to indicate too-short result buffers, others used ENOSPC. Let's unify this on ENOBUFS.
Diffstat (limited to 'src')
-rw-r--r--src/shared/dns-domain.c18
-rw-r--r--src/test/test-dns-domain.c4
2 files changed, 11 insertions, 11 deletions
diff --git a/src/shared/dns-domain.c b/src/shared/dns-domain.c
index 03c0107308..5ac8ad5b7a 100644
--- a/src/shared/dns-domain.c
+++ b/src/shared/dns-domain.c
@@ -53,12 +53,12 @@ int dns_label_unescape(const char **name, char *dest, size_t sz) {
if (*n == 0)
break;
- if (sz <= 0)
- return -ENOSPC;
-
if (r >= DNS_LABEL_MAX)
return -EINVAL;
+ if (sz <= 0)
+ return -ENOBUFS;
+
if (*n == '\\') {
/* Escaped character */
@@ -192,7 +192,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) {
if (l <= 0 || l > DNS_LABEL_MAX)
return -EINVAL;
if (sz < 1)
- return -ENOSPC;
+ return -ENOBUFS;
assert(p);
assert(dest);
@@ -205,7 +205,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) {
/* Dot or backslash */
if (sz < 3)
- return -ENOSPC;
+ return -ENOBUFS;
*(q++) = '\\';
*(q++) = *p;
@@ -221,7 +221,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) {
/* Proper character */
if (sz < 2)
- return -ENOSPC;
+ return -ENOBUFS;
*(q++) = *p;
sz -= 1;
@@ -231,7 +231,7 @@ int dns_label_escape(const char *p, size_t l, char *dest, size_t sz) {
/* Everything else */
if (sz < 5)
- return -ENOSPC;
+ return -ENOBUFS;
*(q++) = '\\';
*(q++) = '0' + (char) ((uint8_t) *p / 100);
@@ -315,7 +315,7 @@ int dns_label_apply_idna(const char *encoded, size_t encoded_size, char *decoded
if (l <= 0 || l > DNS_LABEL_MAX)
return -EINVAL;
if (l > decoded_max)
- return -ENOSPC;
+ return -ENOBUFS;
memcpy(decoded, buffer, l);
@@ -366,7 +366,7 @@ int dns_label_undo_idna(const char *encoded, size_t encoded_size, char *decoded,
if (w <= 0)
return -EINVAL;
if (w > decoded_max)
- return -ENOSPC;
+ return -ENOBUFS;
memcpy(decoded, result, w);
diff --git a/src/test/test-dns-domain.c b/src/test/test-dns-domain.c
index a1795b3be2..7f53a8cc56 100644
--- a/src/test/test-dns-domain.c
+++ b/src/test/test-dns-domain.c
@@ -39,7 +39,7 @@ static void test_dns_label_unescape_one(const char *what, const char *expect, si
static void test_dns_label_unescape(void) {
test_dns_label_unescape_one("hallo", "hallo", 6, 5);
- test_dns_label_unescape_one("hallo", "hallo", 4, -ENOSPC);
+ test_dns_label_unescape_one("hallo", "hallo", 4, -ENOBUFS);
test_dns_label_unescape_one("", "", 10, 0);
test_dns_label_unescape_one("hallo\\.foobar", "hallo.foobar", 20, 12);
test_dns_label_unescape_one("hallo.foobar", "hallo", 10, 5);
@@ -132,7 +132,7 @@ static void test_dns_label_unescape_suffix_one(const char *what, const char *exp
static void test_dns_label_unescape_suffix(void) {
test_dns_label_unescape_suffix_one("hallo", "hallo", "", 6, 5, 0);
- test_dns_label_unescape_suffix_one("hallo", "hallo", "", 4, -ENOSPC, -ENOSPC);
+ test_dns_label_unescape_suffix_one("hallo", "hallo", "", 4, -ENOBUFS, -ENOBUFS);
test_dns_label_unescape_suffix_one("", "", "", 10, 0, 0);
test_dns_label_unescape_suffix_one("hallo\\.foobar", "hallo.foobar", "", 20, 12, 0);
test_dns_label_unescape_suffix_one("hallo.foobar", "foobar", "hallo", 10, 6, 5);