aboutsummaryrefslogtreecommitdiff
path: root/puny.c
diff options
context:
space:
mode:
authorOmar Polo <op@omarpolo.com>2021-01-27 15:35:09 +0000
committerOmar Polo <op@omarpolo.com>2021-01-27 15:35:09 +0000
commit44ee1bac8bc4ca2f216297d00ee6677f49fe3342 (patch)
treef5dd2f4d107eb8aade8d20f4e81c746f1b95064c /puny.c
parent22c6d6334deef920cd0212ca92f61d315860177a (diff)
use starts_with in puny.c
Diffstat (limited to 'puny.c')
-rw-r--r--puny.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/puny.c b/puny.c
index f465198..5fa6812 100644
--- a/puny.c
+++ b/puny.c
@@ -142,11 +142,7 @@ decode(const char *str, char *out, size_t len)
unsigned int numpoints;
const char *s;
- if (str == NULL || len <= 4)
- return 0;
-
- /* todo: starts_with */
- if (strstr(str, "xn--") != str) {
+ if (!starts_with(str, "xn--")) {
strncpy(out, str, len);
return 1;
}
@@ -223,6 +219,8 @@ puny_decode(const char *hostname, char *out, size_t len)
size_t l;
memset(out, 0, len);
+ if (hostname == NULL)
+ return 1;
s = hostname;
for (;;) {