Move logic into wind_punycode_label_toascii()

git-svn-id: svn://svn.h5l.se/heimdal/trunk/heimdal@22594 ec53bebd-3082-4978-b11e-865c3cabbd6b
This commit is contained in:
Love Hörnquist Åstrand
2008-02-12 11:58:37 +00:00
parent f8f1134546
commit eddf3cbee8

View File

@@ -73,7 +73,7 @@ lookup(const char *name)
size_t u_len = strlen(name); size_t u_len = strlen(name);
uint32_t *u = malloc(u_len * sizeof(uint32_t)); uint32_t *u = malloc(u_len * sizeof(uint32_t));
size_t norm_len = u_len; size_t norm_len = u_len * 2;
uint32_t *norm = malloc(norm_len * sizeof(uint32_t)); uint32_t *norm = malloc(norm_len * sizeof(uint32_t));
if (u == NULL || norm == NULL) if (u == NULL || norm == NULL)
@@ -95,16 +95,10 @@ lookup(const char *name)
for (j = i; j < norm_len && !is_separator(norm[j]); ++j) for (j = i; j < norm_len && !is_separator(norm[j]); ++j)
; ;
len = sizeof(encoded) - (ep - encoded); len = sizeof(encoded) - (ep - encoded);
ret = wind_punycode_toascii(norm + i, j - i, ep, &len); ret = wind_punycode_label_toascii(norm + i, j - i, ep, &len);
if (ret < 0) if (ret)
errx(1, "punycode failed"); errx(1, "punycode failed");
if (ret) {
memmove(ep + 4, ep, len);
memcpy(ep, "xn--", 4);
ep += 4;
} else {
--len;
}
ep += len; ep += len;
*ep++ = '.'; *ep++ = '.';
i = j; i = j;