FreeBSD Bugzilla – Attachment 211359 Details for
Bug 243862
[patch] whois(1) does not recurse to servers that include a port number
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
better patch
whois.port.diff (text/plain), 3.73 KB, created by
ben
on 2020-02-04 22:00:43 UTC
(
hide
)
Description:
better patch
Filename:
MIME Type:
Creator:
ben
Created:
2020-02-04 22:00:43 UTC
Size:
3.73 KB
patch
obsolete
>Index: whois.c >=================================================================== >--- whois.c (revision 357392) >+++ whois.c (working copy) >@@ -117,6 +117,7 @@ > WHOIS_REFERRAL("Whois Server:"), > WHOIS_REFERRAL("Registrar WHOIS Server:"), /* corporatedomains.com */ > WHOIS_REFERRAL("ReferralServer: whois://"), /* ARIN */ >+ WHOIS_REFERRAL("ReferralServer: rwhois://"), /* ARIN */ > WHOIS_REFERRAL("descr: region. Please query"), /* AfriNIC */ > { NULL, 0 } > }; >@@ -156,10 +157,10 @@ > static const char *port = DEFAULT_PORT; > > static const char *choose_server(char *); >-static struct addrinfo *gethostinfo(char const *host, int exitnoname); >+static struct addrinfo *gethostinfo(const char *, const char *, int); > static void s_asprintf(char **ret, const char *format, ...) __printflike(2, 3); > static void usage(void); >-static void whois(const char *, const char *, int); >+static void whois(const char *, const char *, const char *, int); > > int > main(int argc, char *argv[]) >@@ -255,11 +256,11 @@ > if (country != NULL) { > char *qnichost; > s_asprintf(&qnichost, "%s%s", country, QNICHOST_TAIL); >- whois(*argv, qnichost, flags); >+ whois(*argv, qnichost, port, flags); > free(qnichost); > } else > whois(*argv, host != NULL ? host : >- choose_server(*argv), flags); >+ choose_server(*argv), port, flags); > reset_rir(); > argv++; > } >@@ -283,7 +284,7 @@ > } > > static struct addrinfo * >-gethostinfo(char const *host, int exit_on_noname) >+gethostinfo(const char *host, const char *hport, int exit_on_noname) > { > struct addrinfo hints, *res; > int error; >@@ -293,7 +294,7 @@ > hints.ai_family = AF_UNSPEC; > hints.ai_socktype = SOCK_STREAM; > res = NULL; >- error = getaddrinfo(host, port, &hints, &res); >+ error = getaddrinfo(host, hport, &hints, &res); > if (error && (exit_on_noname || error != EAI_NONAME)) > err(EX_NOHOST, "%s: %s", host, gai_strerror(error)); > return (res); >@@ -444,15 +445,15 @@ > } > > static void >-whois(const char *query, const char *hostname, int flags) >+whois(const char *query, const char *hostname, const char *hostport, int flags) > { > FILE *fp; > struct addrinfo *hostres; >- char *buf, *host, *nhost, *p; >+ char *buf, *host, *nhost, *nport, *p; > int comment, s, f; > size_t len, i; > >- hostres = gethostinfo(hostname, 1); >+ hostres = gethostinfo(hostname, hostport, 1); > s = connect_to_any_host(hostres); > if (s == -1) > err(EX_OSERR, "connect()"); >@@ -532,14 +533,35 @@ > SCAN(p, buf+len, *p == ' '); > host = p; > SCAN(p, buf+len, ishost(*p)); >- if (p > host) >+ if (p > host) { >+ char *pstr; >+ > s_asprintf(&nhost, "%.*s", > (int)(p - host), host); >+ >+ if (*p != ':') { >+ s_asprintf(&nport, "%s", port); >+ break; >+ } >+ >+ pstr = ++p; >+ SCAN(p, buf+len, isdigit(*p)); >+ if (p > pstr && (p - pstr) < 6) { >+ s_asprintf(&nport, "%.*s", >+ (int)(p - pstr), pstr); >+ break; >+ } >+ >+ /* Invalid port; don't recurse */ >+ free(nhost); >+ nhost = NULL; >+ } > break; > } > for (i = 0; actually_arin[i] != NULL; i++) { > if (strncmp(buf, actually_arin[i], len) == 0) { > s_asprintf(&nhost, "%s", ANICHOST); >+ s_asprintf(&nport, "%s", port); > break; > } > } >@@ -567,6 +589,7 @@ > strcasecmp(try_rir[i].host, nhost) == 0) { > free(nhost); > nhost = NULL; >+ free(nport); > f = 1; > } > } >@@ -576,6 +599,8 @@ > if (try_rir[i].loop == 0) { > s_asprintf(&nhost, "%s", > try_rir[i].host); >+ s_asprintf(&nport, "%s", >+ port); > break; > } > } >@@ -584,9 +609,10 @@ > /* Ignore self-referrals */ > if (strcasecmp(hostname, nhost) != 0) { > printf("# %s\n\n", nhost); >- whois(query, nhost, flags); >+ whois(query, nhost, nport, flags); > } > free(nhost); >+ free(nport); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
Attachments on
bug 243862
:
211337
| 211359