diff options
author | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 13:58:20 +0200 |
---|---|---|
committer | Jannis Hoffmann <jannis@fehcom.de> | 2024-07-09 13:58:20 +0200 |
commit | 249866e3d1e11dc72eaa1305f4bb479ded92ef38 (patch) | |
tree | 7118c5f58e29fe61c100e4d067bb90ba8d52589e /dnsstub/dns_dfd.c | |
parent | 96cf8dffe4f7b0b910f790066ae622dc429eb522 (diff) |
reorganized file structure
Moved c files into src/.
Corrected VERSION file.
Removed BUILD and FILES.
Diffstat (limited to 'dnsstub/dns_dfd.c')
-rw-r--r-- | dnsstub/dns_dfd.c | 76 |
1 files changed, 0 insertions, 76 deletions
diff --git a/dnsstub/dns_dfd.c b/dnsstub/dns_dfd.c deleted file mode 100644 index 756a1f8..0000000 --- a/dnsstub/dns_dfd.c +++ /dev/null @@ -1,76 +0,0 @@ -#include "error.h" -#include "alloc.h" -#include "byte.h" -#include "dnsresolv.h" - -/** - @file dns_dfd.c - @author djb - @source ucspi-tcp - @brief domain name qualification (domain from dot) -*/ - -int dns_domain_fromdot(char **out,const char *buf,unsigned int n) -{ - char label[63]; - unsigned int labellen = 0; /* <= sizeof label */ - char name[255]; - unsigned int namelen = 0; /* <= sizeof name */ - char ch; - char *x; - - errno = EPROTO; - - for (;;) { - if (!n) break; - ch = *buf++; --n; - if (ch == '.') { - if (labellen) { - if (namelen + labellen + 1 > sizeof(name)) return 0; - name[namelen++] = labellen; - byte_copy(name + namelen,labellen,label); - namelen += labellen; - labellen = 0; - } - continue; - } - if (ch == '\\') { // octal -> decimal - if (!n) break; - ch = *buf++; --n; - if ((ch >= '0') && (ch <= '7')) { - ch -= '0'; - if (n && (*buf >= '0') && (*buf <= '7')) { - ch <<= 3; - ch += *buf - '0'; - ++buf; --n; - if (n && (*buf >= '0') && (*buf <= '7')) { - ch <<= 3; - ch += *buf - '0'; - ++buf; --n; - } - } - } - } - if (labellen >= sizeof(label)) return 0; - label[labellen++] = ch; - } - - if (labellen) { - if (namelen + labellen + 1 > sizeof(name)) return 0; - name[namelen++] = labellen; - byte_copy(name + namelen,labellen,label); - namelen += labellen; - labellen = 0; - } - - if (namelen + 1 > sizeof(name)) return 0; - name[namelen++] = 0; - - x = alloc(namelen); - if (!x) return DNS_MEM; - byte_copy(x,namelen,name); - - if (*out) alloc_free(*out); - *out = x; - return 1; -} |