]> asedeno.scripts.mit.edu Git - PuTTY.git/commitdiff
from_backend() should always be called with len > 0. Only rlogin
authorSimon Tatham <anakin@pobox.com>
Fri, 1 Mar 2002 13:17:45 +0000 (13:17 +0000)
committerSimon Tatham <anakin@pobox.com>
Fri, 1 Mar 2002 13:17:45 +0000 (13:17 +0000)
mode ever failed to do this, and only Plink actually had a problem
with it, so this didn't become obvious for a while. rlogin mode is
fixed, and all implementations of from_backend() now contain an
assertion so that we should spot errors of this type more quickly in
future.

[originally from svn r1571]

plink.c
psftp.c
rlogin.c
scp.c
terminal.c

diff --git a/plink.c b/plink.c
index b7a2fd4bfe99c5e4172c3f39cb767534d78e4dc1..b2c07acc306e6bf713f13af32a813472dcacc50a 100644 (file)
--- a/plink.c
+++ b/plink.c
@@ -8,6 +8,7 @@
 #include <windows.h>
 #include <stdio.h>
 #include <stdlib.h>
+#include <assert.h>
 #include <stdarg.h>
 
 #define PUTTY_DO_GLOBALS              /* actually _define_ globals */
@@ -147,6 +148,8 @@ int from_backend(int is_stderr, char *data, int len)
     HANDLE h = (is_stderr ? errhandle : outhandle);
     int osize, esize;
 
+    assert(len > 0);
+
     if (is_stderr) {
        bufchain_add(&stderr_data, data, len);
        try_output(1);
diff --git a/psftp.c b/psftp.c
index ead8614047b8562713c6d875cc2d83c281e949f6..094e68b0ce417b3d9cac3ed40894ce33194991c3 100644 (file)
--- a/psftp.c
+++ b/psftp.c
@@ -1512,6 +1512,8 @@ int from_backend(int is_stderr, char *data, int datalen)
     unsigned char *p = (unsigned char *) data;
     unsigned len = (unsigned) datalen;
 
+    assert(len > 0);
+
     /*
      * stderr data is just spouted to local stderr and otherwise
      * ignored.
index ba7dd37bd64cb429db15c9bfb4bbe088e51755f8..a80d12e3cea6d49e6a9aeb6342829b5b5acb02e3 100644 (file)
--- a/rlogin.c
+++ b/rlogin.c
@@ -68,7 +68,8 @@ static int rlogin_receive(Plug plug, int urgent, char *data, int len)
            }
            firstbyte = 0;
        }
-       c_write(data, len);
+       if (len > 0)
+            c_write(data, len);
     }
     return 1;
 }
diff --git a/scp.c b/scp.c
index 60ca11cb0050c8f901641bd838cf5a725850b8f8..34f6ffb5bdff2d9ac805b54084b416e8fb24463d 100644 (file)
--- a/scp.c
+++ b/scp.c
@@ -268,6 +268,8 @@ int from_backend(int is_stderr, char *data, int datalen)
     unsigned char *p = (unsigned char *) data;
     unsigned len = (unsigned) datalen;
 
+    assert(len > 0);
+
     /*
      * stderr data is just spouted to local stderr and otherwise
      * ignored.
index 1c817dacaab6a742d81cc8bc7ede75ba3976efa4..d76d7349a14b6eca0e26d43140f0628ad9a6a081 100644 (file)
@@ -3603,6 +3603,8 @@ int term_ldisc(int option)
  */
 int from_backend(int is_stderr, char *data, int len)
 {
+    assert(len > 0);
+
     bufchain_add(&inbuf, data, len);
 
     /*