- /* skip if last char is not a digit (i.e. not an address) */
- /* (don't check first char - might be 11.22.33.44.an.isp) */
- if (!*tok) return 0; /* nothing to check */
- if (!isdigit(*(unsigned char*)tok+strlen(tok)-1)) return 0;
+ /* Fail quietly if tok is a hostname (not an address) */
+ if (strspn(tok, ".0123456789") != len
+#ifdef INET6
+ && strchr(tok, ':') == NULL
+#endif
+ ) {
+ if (p)
+ *p = '/';
+ return 0;
+ }