Passing SFTP options when using SCP

Chris Rapier rapier at psc.edu
Tue Dec 13 06:03:20 AEDT 2022


Couple of points,

On 12/7/22 9:03 PM, Damien Miller wrote:

> +		case 'X':
> +			/* Please keep in sync with ssh.c -X */
> +			if (strncmp(optarg, "buffer=", 7) == 0) {
> +				copy_buffer_len = strtol(optarg + 7, &cp, 10);
> +				if (copy_buffer_len == 0 || *cp != '\0') {
> +					fatal("Invalid buffer size \"%s\"",
> +					     optarg + 7);
> +				}
> +			} else if (strncmp(optarg, "nrequests=", 10) == 0) {
> +				num_requests = strtol(optarg + 10, &cp, 10);
> +				if (num_requests == 0 || *cp != '\0') {
> +					fatal("Invalid number of requests "
> +					    "\"%s\"", optarg + 10);

The value tests should probably be 'val <= 0' as opposed to 'val == 0'. 
Also you might want to have the buffer size check for a maximum value. 
With overhead, 256K triggers an "Outbound buffer too long" error. 255K 
seems to work but I haven't done the exact math on that one yet. Lastly, 
if nrequests is set to a ridiculous size (on my system more than 150000) 
it ends up sucking up a lot of memory and stalls. I think that's a buyer 
beware sort of thing but I just wanted to let you know.

Also, not defining the sftp_copy_buflen and sftp_nrequests means that in 
do_sftp_connect the line

	return do_init(*reminp, *remoutp,
	    sftp_copy_buflen, sftp_nrequests, limit_kbps);

Ends up with 0's in there for the buflen and requests. What sort of 
behaviour does that create on the sftp server? It seems to just pull out 
the stops.

Chris


More information about the openssh-unix-dev mailing list