FreeBSD Bugzilla – Attachment 15616 Details for
Bug 28880
[patch] src/usr.bin/whois bug fix
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
file.diff
file.diff (text/plain), 2.12 KB, created by
mike
on 2001-07-10 21:50:01 UTC
(
hide
)
Description:
file.diff
Filename:
MIME Type:
Creator:
mike
Created:
2001-07-10 21:50:01 UTC
Size:
2.12 KB
patch
obsolete
>Index: whois/whois.c >=================================================================== >RCS file: /home/ncvs/src/usr.bin/whois/whois.c,v >retrieving revision 1.20 >diff -u -r1.20 whois.c >--- whois/whois.c 2001/06/27 23:06:47 1.20 >+++ whois/whois.c 2001/07/10 20:38:48 >@@ -79,6 +79,7 @@ > > const char *ip_whois[] = { RNICHOST, PNICHOST, NULL }; > >+static char *choose_server(const char *); > static void usage(void); > static void whois(char *, struct addrinfo *, int); > >@@ -88,7 +89,7 @@ > struct addrinfo hints, *res; > const char *host; > char *qnichost; >- int ch, error, flags, i, j, use_qnichost; >+ int ch, error, flags, use_qnichost; > > #ifdef SOCKS > SOCKSinit(argv[0]); >@@ -159,21 +160,7 @@ > } > while (argc--) { > if (use_qnichost) { >- for (i = j = 0; (*argv)[i]; i++) >- if ((*argv)[i] == '.') >- j = i; >- if (j != 0) { >- if (isdigit(*(*argv + j + 1))) { >- asprintf(&qnichost, "%s", ANICHOST); >- if (qnichost == NULL) >- err(1, "asprintf()"); >- } else { >- asprintf(&qnichost, "%s%s", >- *argv + j + 1, QNICHOST_TAIL); >- if (qnichost == NULL) >- err(1, "asprintf()"); >- } >- >+ if ((qnichost = choose_server(*argv)) != NULL) { > memset(&hints, 0, sizeof(hints)); > hints.ai_flags = 0; > hints.ai_family = AF_UNSPEC; >@@ -202,6 +189,40 @@ > freeaddrinfo(res); > } > exit(0); >+} >+ >+/* >+ * Returns a pointer to newly allocated memory containing the whois server to >+ * be queried, or a NULL pointer, if the correct server couldn't be determined. >+ * The caller must remember to free(3) the allocated memory. >+ */ >+static char * >+choose_server(const char *domain) >+{ >+ size_t len; >+ char *buf, *pos, *retval; >+ >+ if ((buf = strdup(domain)) == NULL) >+ err(1, "strdup()"); >+ len = strlen(buf); >+ while (len && buf[len - 1] == '.') >+ buf[--len] = '\0'; >+ if ((pos = strrchr(buf, '.')) == NULL) { >+ free(buf); >+ return (NULL); >+ } >+ pos++; >+ if (isdigit(*pos)) { >+ asprintf(&retval, "%s", ANICHOST); >+ if (retval == NULL) >+ err(1, "asprintf()"); >+ } else { >+ asprintf(&retval, "%s%s", pos, QNICHOST_TAIL); >+ if (retval == NULL) >+ err(1, "asprintf()"); >+ } >+ free(buf); >+ return (retval); > } > > static void
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 28880
: 15616