summaryrefslogtreecommitdiff
path: root/src/dnsstub/dns_dfd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/dnsstub/dns_dfd.c')
-rw-r--r--src/dnsstub/dns_dfd.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/src/dnsstub/dns_dfd.c b/src/dnsstub/dns_dfd.c
index 756a1f8..645d068 100644
--- a/src/dnsstub/dns_dfd.c
+++ b/src/dnsstub/dns_dfd.c
@@ -1,7 +1,7 @@
-#include "error.h"
#include "alloc.h"
#include "byte.h"
#include "dnsresolv.h"
+#include "error.h"
/**
@file dns_dfd.c
@@ -10,7 +10,7 @@
@brief domain name qualification (domain from dot)
*/
-int dns_domain_fromdot(char **out,const char *buf,unsigned int n)
+int dns_domain_fromdot(char **out, const char *buf, unsigned int n)
{
char label[63];
unsigned int labellen = 0; /* <= sizeof label */
@@ -23,30 +23,34 @@ int dns_domain_fromdot(char **out,const char *buf,unsigned int n)
for (;;) {
if (!n) break;
- ch = *buf++; --n;
+ ch = *buf++;
+ --n;
if (ch == '.') {
if (labellen) {
if (namelen + labellen + 1 > sizeof(name)) return 0;
name[namelen++] = labellen;
- byte_copy(name + namelen,labellen,label);
+ byte_copy(name + namelen, labellen, label);
namelen += labellen;
labellen = 0;
}
continue;
}
- if (ch == '\\') { // octal -> decimal
+ if (ch == '\\') { // octal -> decimal
if (!n) break;
- ch = *buf++; --n;
+ ch = *buf++;
+ --n;
if ((ch >= '0') && (ch <= '7')) {
ch -= '0';
if (n && (*buf >= '0') && (*buf <= '7')) {
ch <<= 3;
ch += *buf - '0';
- ++buf; --n;
+ ++buf;
+ --n;
if (n && (*buf >= '0') && (*buf <= '7')) {
ch <<= 3;
ch += *buf - '0';
- ++buf; --n;
+ ++buf;
+ --n;
}
}
}
@@ -58,7 +62,7 @@ int dns_domain_fromdot(char **out,const char *buf,unsigned int n)
if (labellen) {
if (namelen + labellen + 1 > sizeof(name)) return 0;
name[namelen++] = labellen;
- byte_copy(name + namelen,labellen,label);
+ byte_copy(name + namelen, labellen, label);
namelen += labellen;
labellen = 0;
}
@@ -68,7 +72,7 @@ int dns_domain_fromdot(char **out,const char *buf,unsigned int n)
x = alloc(namelen);
if (!x) return DNS_MEM;
- byte_copy(x,namelen,name);
+ byte_copy(x, namelen, name);
if (*out) alloc_free(*out);
*out = x;