On Thu, Oct 04, 2001 at 01:28:02PM +0400, Andrey A. Chernov wrote:
> On Thu, Oct 04, 2001 at 12:16:40 +0300, Peter Pentchev wrote:
> > +             if ((len == 0) || !isspace(buf[len - 1])) {
>
> Must be isspace((unsigned char)....)
                
On Thu, Oct 04, 2001 at 01:30:42PM +0400, Andrey A. Chernov wrote:
> On Thu, Oct 04, 2001 at 12:16:40 +0300, Peter Pentchev wrote:
> > +                   abuf = calloc(1, len + 1);
> > +                   if (abuf == NULL) {
> > +                           errno = ENOMEM;
> > +                           err(1, "reallocating");
> > +                   }
> 
> To overwrite errno set by calloc() is wrong.

Oops to both :\

OK, here's an updated patch.

G'luck,
Peter

-- 
If the meanings of 'true' and 'false' were switched, then this sentence wouldn't be 
false.

Index: src/usr.bin/whois/whois.c
===================================================================
RCS file: /home/ncvs/src/usr.bin/whois/whois.c,v
retrieving revision 1.24
diff -u -r1.24 whois.c
--- src/usr.bin/whois/whois.c   2001/08/05 19:37:12     1.24
+++ src/usr.bin/whois/whois.c   2001/10/04 14:39:24
@@ -251,7 +251,7 @@
 {
        FILE *sfi, *sfo;
        struct addrinfo *res2;
-       char *buf, *nhost, *p;
+       char *abuf, *buf, *nhost, *p;
        int i, nomatch, s;
        size_t len;
 
@@ -275,7 +275,15 @@
        nhost = NULL;
        nomatch = 0;
        while ((buf = fgetln(sfi, &len)) != NULL) {
-               while (len && isspace(buf[len - 1]))
+               abuf = NULL;
+               if ((len == 0) || !isspace((unsigned char)buf[len - 1])) {
+                       abuf = calloc(1, len + 1);
+                       if (abuf == NULL)
+                               err(1, "reallocating");
+                       memcpy(abuf, buf, len);
+                       buf = abuf;
+               }
+               while (len && isspace((unsigned char)buf[len - 1]))
                        buf[--len] = '\0';
 
                if ((flags & WHOIS_RECURSE) && nhost == NULL) {
@@ -304,6 +312,7 @@
                                nomatch = 1;
                }
                printf("%s\n", buf);
+               free(abuf);
        }
 
        /* Do second lookup as needed. */

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-net" in the body of the message

Reply via email to