commit 0cd6675437e580ae2ac585d6b0bff325990cf8b8 from: Omar Polo date: Wed Jan 27 15:41:33 2021 UTC compiler warnings commit - b736ca35f220381799b62c731710c8d593dcd296 commit + 0cd6675437e580ae2ac585d6b0bff325990cf8b8 blob - 5fa68122b51bed663359aa6099dec26af3a41def blob + 304db7a56560d97db8d2cfe8d760332fd7f46b6e --- puny.c +++ puny.c @@ -52,9 +52,11 @@ static const char * copy_until_delimiter(const char *s, char *out, size_t len) { char *end, *t; + size_t l; end = strchr(s, '\0'); - if (end - s > len) + l = end - s; + if (l > len) return NULL; for (t = end; t >= s; --t) @@ -92,7 +94,6 @@ static int insert(char *out, size_t len, int codepoint, size_t i) { int l; - size_t outlen; char *t; if (codepoint <= 0x7F) @@ -203,7 +204,7 @@ decode(const char *str, char *out, size_t len) return 1; } -const char * +static const char * end_of_component(const char *hostname) { for (; *hostname != '\0' && *hostname != '.'; ++hostname) @@ -225,7 +226,8 @@ puny_decode(const char *hostname, char *out, size_t le s = hostname; for (;;) { end = end_of_component(s); - if (end - s >= sizeof(comp)) + l = end - s; + if (l >= sizeof(comp)) return 0; memcpy(comp, s, end - s);