| Summary: | Re: whois gives contents of /etc/services for bad .biz lookups | ||
|---|---|---|---|
| Product: | Base System | Reporter: | Ivan Brawley <brawley> |
| Component: | bin | Assignee: | Peter Pentchev <roam> |
| Status: | Closed FIXED | ||
| Severity: | Affects Only Me | CC: | newton |
| Priority: | Normal | ||
| Version: | 1.0-RELEASE | ||
| Hardware: | Any | ||
| OS: | Any | ||
State Changed From-To: open->closed Do not munge subject/synopsis lines. Responsible Changed From-To: gnats-admin->roam Roam again. :) see PR 31002, this is a follow-up |
--ELM710674628-452-0_ Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Ivan Brawley wrote saying: } They have got a suggested patch there too. } } Might have a look at the lastest code for whois... The latest code in the cvs repo is too old, however, tryed out the patch and that works. ivan. -- Ivan Brawley Internode Professional Access. --ELM710674628-452-0_ Content-Type: text/plain; charset=ISO-8859-1 Content-Disposition: attachment; filename=whois.c.patch Content-Description: whois.c.patch Content-Transfer-Encoding: 7bit *** whois.c.orig Wed Oct 3 17:44:14 2001 --- whois.c Wed Oct 3 17:46:39 2001 *************** *** 51,56 **** --- 51,57 ---- #include <arpa/inet.h> #include <ctype.h> #include <err.h> + #include <errno.h> #include <netdb.h> #include <stdarg.h> #include <stdio.h> *************** *** 243,249 **** { FILE *sfi, *sfo; struct addrinfo *res2; ! char *buf, *nhost, *p; int i, nomatch, s; size_t len; --- 244,250 ---- { FILE *sfi, *sfo; struct addrinfo *res2; ! char *abuf, *buf, *nhost, *p; int i, nomatch, s; size_t len; *************** *** 267,272 **** --- 268,283 ---- nhost = NULL; nomatch = 0; while ((buf = fgetln(sfi, &len)) != NULL) { + abuf = NULL; + if ((len == 0) || !isspace(buf[len - 1])) { + abuf = calloc(1, len+1); + if (abuf == NULL) { + errno = ENOMEM; + err(1, "reallocating"); + } + memcpy(abuf, buf, len); + buf = abuf; + } while (len && isspace(buf[len - 1])) buf[--len] = '\0'; *************** *** 296,301 **** --- 307,313 ---- nomatch = 1; } printf("%s\n", buf); + free(abuf); } /* Do second lookup as needed. */ --ELM710674628-452-0_--