commit - 473e4531d5c55ef25dde8df5b57ef503ef1aa218
commit + 35cf19e3f36688927ff28aa2b45108cda5f9a8d8
blob - 8e16f487c065310dd2d62d64e1a49777ea876b18
blob + 7f9216e14774690e29c10e082732daf65c9dd451
--- gmid.h
+++ gmid.h
#define HOSTSLEN 64
#define LOCLEN 32
-/* RFC1034 imposes this limit. 63+1 for the NUL-terminator */
-#define DOMAIN_NAME_LEN (63+1)
+/* maximum hostname and label length, +1 for the NUL-terminator */
+#define DOMAIN_NAME_LEN (253+1)
+#define LABEL_LEN (63+1)
#define LOGE(c, fmt, ...) logs(LOG_ERR, c, fmt, __VA_ARGS__)
#define LOGW(c, fmt, ...) logs(LOG_WARNING, c, fmt, __VA_ARGS__)
blob - 304db7a56560d97db8d2cfe8d760332fd7f46b6e
blob + c00314c4ed91dbe753d78fd4e479fd0c3a7ab3c5
--- puny.c
+++ puny.c
}
static const char *
-copy_until_delimiter(const char *s, char *out, size_t len)
+copy_label(const char *s, char *out, size_t len)
{
char *end, *t;
size_t l;
switch (l) {
case 2:
t[1] = ( codepoint & 0x3F) + 0x80;
- t[0] = ((codepoint >> 6) & 0x1F) + 0xC0;
+ t[0] = ((codepoint >> 6) & 0x1F) + 0xC0;
break;
case 3:
t[2] = ( codepoint & 0x3F) + 0x80;
- t[1] = ((codepoint >> 6) & 0x3F) + 0x80;
+ t[1] = ((codepoint >> 6) & 0x3F) + 0x80;
t[0] = ((codepoint >> 12) & 0x0F) + 0xE0;
break;
case 4:
t[3] = ( codepoint & 0x3F) + 0x80;
- t[2] = ((codepoint >> 6) & 0x3F) + 0x80;
+ t[2] = ((codepoint >> 6) & 0x3F) + 0x80;
t[1] = ((codepoint >> 12) & 0x3F) + 0x80;
t[0] = ((codepoint >> 18) & 0x07) + 0xF0;
break;
str += 4;
if (strchr(str, '-') != NULL) {
- if ((s = copy_until_delimiter(str, out, len)) == NULL)
+ if ((s = copy_label(str, out, len)) == NULL)
return 0;
if (*s == '-')
s++;
}
static const char *
-end_of_component(const char *hostname)
+end_of_label(const char *hostname)
{
for (; *hostname != '\0' && *hostname != '.'; ++hostname)
; /* nop */
int
puny_decode(const char *hostname, char *out, size_t len)
{
- char comp[DOMAIN_NAME_LEN];
+ char label[LABEL_LEN];
const char *s, *end;
size_t l;
for (;;) {
end = end_of_component(s);
l = end - s;
- if (l >= sizeof(comp))
+ if (l >= sizeof(label))
return 0;
- memcpy(comp, s, end - s);
- comp[end - s] = '\0';
+ memcpy(label, s, l);
+ label[l] = '\0';
- if (!decode(comp, out, len))
+ if (!decode(label, out, len))
return 0;
if (*end == '\0')