bug in scp (OpenSSH)

Harald Koenig koenig at tat.physik.uni-tuebingen.de
Wed Sep 5 02:40:14 EST 2001


On Aug 31, Markus Friedl wrote:

> On Fri, Aug 31, 2001 at 12:20:23PM +0200, Roman Drahtmueller wrote:
> > Are you serious that you want to keep a bug because "this is how the rcp
> > protocol works"? It is clearly flawed.
> 
> should we really change the semantics of a 17 year old protocol,
> if you can use sftp, rsync or tar instead?

if behaviour is broken and it's not explicitly designed to be broken
that way: yes.  (and it _is_ broken).

I tried "rcp" too and indeed, it does copy binary trash too.
fortuneately, at least with my ~8 kbytes source file, no
passwd entries show up in rcp buffers but only parts of
/etc/services.  but who knows what might show up for longer source
files ?!


> however, you can try to modify sink() to truncate the ofd if
> response() returns an error. so the data will be sent but
> discarded. i'm not sure whether i like the idea. it might
> break other things.

your 2nd patch below doesn't make any difference.
destination file still gets filled with null bytes.

> 
> 
> -m
> 
> Index: scp.c
> ===================================================================
> RCS file: /home/markus/cvs/ssh/scp.c,v
> retrieving revision 1.81
> diff -u -r1.81 scp.c
> --- scp.c	2001/08/29 20:44:03	1.81
> +++ scp.c	2001/08/31 11:17:53
> @@ -853,11 +853,15 @@
>  					run_err("%s: set mode: %s",
>  					    np, strerror(errno));
>  		}
> +		if (response() < 0) {
> +			ftruncate(ofd, 0);
> +			wrerr = YES;
> +			wrerrno = EIO;
> +		}
>  		if (close(ofd) == -1) {
>  			wrerr = YES;
>  			wrerrno = errno;
>  		}
> -		(void) response();
>  		if (setimes && wrerr == NO) {
>  			setimes = 0;
>  			if (utimes(np, tv) < 0) {


Harald
-- 
All SCSI disks will from now on                     ___       _____
be required to send an email notice                0--,|    /OOOOOOO\
24 hours prior to complete hardware failure!      <_/  /  /OOOOOOOOOOO\
                                                    \  \/OOOOOOOOOOOOOOO\
                                                      \ OOOOOOOOOOOOOOOOO|//
Harald Koenig,                                         \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik                              //  /     \\  \
koenig at tat.physik.uni-tuebingen.de                     ^^^^^       ^^^^^



More information about the openssh-unix-dev mailing list