cURL / Mailing Lists / curl-users / Single Mail

curl-users

bug in telnet.c?

From: Hans Steegers <J.Steegers_at_chello.nl>
Date: Tue, 27 Nov 2001 14:21:32 +0100

I noticed some strange behaviour when trying to use libcurl for
some telnet stuff. I couldn't redirect stdin, but redirecting
stdout-input worked instead. Looking into the sources I found out
that actually stdout was used for input:

In lib/telnet.c is says "read from stdin", but the read is read(1,buf,255);
which is stdout!
(starting at line 1158:)
    default: /* read! */
      if(FD_ISSET(1, &readfd)) { /* read from stdin */
        unsigned char outbuf[2];
        int out_count = 0;
        size_t bytes_written;
        char *buffer = buf;

        nread = read(1, buf, 255);

Is this intended, to use stdout for reading?
Or is it a bug? If so:

--- telnet.c.org Thu Oct 11 11:35:53 2001
+++ telnet.c Sun Nov 25 16:46:30 2001
@@ -1162,7 +1162,8 @@ CURLcode Curl_telnet(struct connectdata
         size_t bytes_written;
         char *buffer = buf;

- nread = read(1, buf, 255);
+// nread = read(1, buf, 255);
+ nread = read(0, buf, 255);

         while(nread--) {
           outbuf[0] = *buffer++;

Hans Steegers
Received on 2001-11-27