cURL / Mailing Lists / curl-library / Single Mail

curl-library

Re: Automated telnet problems

From: Pierre Brico <pierre.brico_at_tsdsoftware.eu>
Date: Thu, 12 Mar 2009 09:46:28 +0100

Hello,

Here you have the diff -u starting from the latest version of telnet.c in
the cvs repository:

$ diff -u /d/telnet.c telnet.c
--- /d/telnet.c Thu Mar 12 08:36:08 2009
+++ telnet.c Thu Mar 12 09:21:28 2009
@@ -108,7 +108,7 @@
 #endif

 static
-void telrcv(struct connectdata *,
+CURLcode telrcv(struct connectdata *,
             const unsigned char *inbuf, /* Data received from socket */
             ssize_t count); /* Number of bytes received */

@@ -952,7 +952,7 @@
 }

 static
-void telrcv(struct connectdata *conn,
+CURLcode telrcv(struct connectdata *conn,
             const unsigned char *inbuf, /* Data received from socket */
             ssize_t count) /* Number of bytes received */
 {
@@ -961,10 +961,14 @@
   int startwrite=-1;
   struct SessionHandle *data = conn->data;
   struct TELNET *tn = (struct TELNET *)data->state.proto.telnet;
+ CURLcode result;

 #define startskipping() \
- if(startwrite >= 0) \
- Curl_client_write(conn, CLIENTWRITE_BODY, (char
*)&inbuf[startwrite], in-startwrite); \
+ if(startwrite >= 0) { \
+ result = Curl_client_write(conn, CLIENTWRITE_BODY, (char
*)&inbuf[startwrite], in-startwrite); \
+ if (result != CURLE_OK) \
+ return result; \
+ } \
     startwrite = -1

 #define writebyte() \
@@ -1119,6 +1123,8 @@
     ++in;
   }
   bufferflush();
+
+ return CURLE_OK;
 }

 /* Escape and send a telnet data block */
@@ -1389,7 +1395,11 @@
           break;
         }

- telrcv(conn, (unsigned char *)buf, nread);
+ code = telrcv(conn, (unsigned char *)buf, nread);
+ if(code) {
+ keepon = FALSE;
+ break;
+ }

         fflush(stdout);

@@ -1475,7 +1485,11 @@
           break;
         }

- telrcv(conn, (unsigned char *)buf, nread);
+ code = telrcv(conn, (unsigned char *)buf, nread);
+ if(code) {
+ keepon = FALSE;
+ break;
+ }

         /* Negotiate if the peer has started negotiating,
            otherwise don't. We don't want to speak telnet with

Regards

On Wed, Mar 11, 2009 at 11:12 PM, Daniel Stenberg <daniel_at_haxx.se> wrote:

> On Wed, 11 Mar 2009, Pierre Brico wrote:
>
> Here is a patch for the second issue (libcurl didn't report error when
>> write_callback returns unexpected value):
>>
>
> Great, thanks! Can you please use diff -u and repost it?
>
> (And please don't top-post and full-quote on this list.)
>
> --
>
> / daniel.haxx.se
>
Received on 2009-03-12