Граф коммитов

33 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 896bb7c74d Tighten up a lot of casts from unsigned to int which are read by one
of the GET_32BIT macros and then used as length fields. Missing bounds
checks against zero have been added, and also I've introduced a helper
function toint() which casts from unsigned to int in such a way as to
avoid C undefined behaviour, since I'm not sure I trust compilers any
more to do the obviously sensible thing.

[originally from svn r9918]
2013-07-14 10:45:54 +00:00
Simon Tatham c925526e3f xfer_{up,down}load_gotpkt free their input sftp_packet as a side
effect of handling it, but they do not free it if it isn't a packet
they recognise as part of their upload/download. Invent a return value
that specifically signals this, and consistently free pktin at every
call site if that return value comes back. Also, ensure that that
return value also always comes with something meaningful in fxp_error.

[originally from svn r9915]
2013-07-11 17:24:53 +00:00
Simon Tatham 2c586ee2cd Clean up handling of the return value from sftp_find_request. In many
places we simply enforce by assertion that it will match the request
we sent out a moment ago: in fact it can also return NULL, so it makes
more sense to report a proper error message if it doesn't return the
expected value, and while we're at it, have that error message
whatever message was helpfully left in fxp_error() by
sftp_find_request when it failed.

To do this, I've written a centralised function in psftp.c called
sftp_wait_for_reply, which is handed a request that's just been sent
out and deals with the mechanics of waiting for its reply, returning
the reply when it arrives, and aborting with a sensible error if
anything else arrives instead. The numerous sites in psftp.c which
called sftp_find_request have all been rewritten to do this instead,
and as a side effect they now look more sensible. The only other uses
of sftp_find_request were in xfer_*load_gotpkt, which had to be
tweaked in its own way.

While I'm here, also fix memory management in sftp_find_request, which
was freeing its input packet on some but not all error return paths.

[originally from svn r9894]
2013-07-06 20:43:21 +00:00
Simon Tatham 1ac65ff017 Use a single sftp_senddata() to send each SFTP packet, rather than
using one for the length field and one for the rest of the packet
contents. Since sftp_senddata() has no queuing or deferral mechanism
but instead constructs and sends an SSH2_MSG_CHANNEL_DATA message
immediately, this change has the effect of ceasing to split every SFTP
packet across two SSH messages.

[originally from svn r9603]
2012-08-12 20:17:13 +00:00
Simon Tatham 5c00b581c8 Propagate file permissions in both directions in Unix pscp and psftp.
I think I have to consider this to be a separate but related change to
the wishlist item 'pscp-filemodes'; that was written before the Unix
port existed, and referred to the ability to configure the permissions
used for files copied from Windows to Unix - which is still not done.

[originally from svn r9260]
2011-08-11 17:59:30 +00:00
Simon Tatham 42801b7e9e Get rid of all the MSVC warnings.
[originally from svn r7086]
2007-01-09 18:24:07 +00:00
Simon Tatham bbec032476 Lionel Fourquaux offers this very simple patch to speed up SFTP,
simply by upping the packet sizes and maximum in-flight packet
count. Got to be worth a try, I think!

[originally from svn r6722]
2006-06-02 08:46:34 +00:00
Jacob Nevins 6eec320f0b Unify GET_32BIT()/PUT_32BIT() et al from numerous source files into misc.h.
I've done a bit of testing (not exhaustive), and I don't _think_ I've broken
anything...

[originally from svn r5632]
2005-04-12 20:04:56 +00:00
Simon Tatham e902c235ad Per Gunnar Floe spotted a reversed test in sftp_cleanup_requests().
[originally from svn r5394]
2005-02-25 09:59:24 +00:00
Simon Tatham 893d187b81 Additional robustness to SFTP packet parsing and memory allocation.
[originally from svn r5358]
2005-02-20 10:30:05 +00:00
Simon Tatham d649075539 The xfer mechanism wasn't gracefully terminating when an error was
encountered part way through transfer. In particular, this caused
psftp to hang (waiting for FXP_READ replies which had already
arrived) if you try `get' (without -r) on a remote directory.

[originally from svn r5005]
2004-12-17 13:39:41 +00:00
Simon Tatham 7a1eae7ff2 Joe Yates's memory leak patches.
[originally from svn r3650]
2003-12-19 12:44:46 +00:00
Simon Tatham 77cc301862 Uploads turn out to be much easier than downloads, so here's faster
upload support in PSFTP as well.

[originally from svn r3470]
2003-09-28 14:24:01 +00:00
Simon Tatham bc83c59aa7 First cut at speeding up SFTP. Generic download-management code in
sftp.c, and psftp.c now uses that instead of going it alone. Should
in principle be easily installed in PSCP as well, but I haven't done
it yet; also it only handles downloads, not uploads, and finally it
doesn't yet properly calculate the correct number of parallel
requests to queue. Still, it's a start, and in my own tests it
seemed to perform as expected (download speed suddenly became
roughly what you'd expect from the available bandwidth, and
decreased by roughly the expected number of round-trip times).

[originally from svn r3468]
2003-09-27 17:52:34 +00:00
Simon Tatham 66fa6f320e And just to prove that psftp.c really is now platform-independent
... here's a Unix port of PSFTP. Woo. (Oddly PSCP looks to be
somewhat harder; there's more Windows code interleaved than there
was in PSFTP.)

[originally from svn r3419]
2003-08-24 13:22:17 +00:00
Simon Tatham 5bd604f53f Phase 1a of SFTP re-engineering: fix the glaring memory and request
ID leak in the previous checkin. Oops :-)

[originally from svn r3319]
2003-06-29 14:47:14 +00:00
Simon Tatham 3e44064f32 First phase of SFTP re-engineering. Each base-level fxp_* function
has been split into a send half and a receive half, so that callers
can set several requests in motion at a time and deal with the
responses in whatever order they arrive.

[originally from svn r3318]
2003-06-29 14:26:09 +00:00
Simon Tatham d36a4c3685 Introduced wrapper macros snew(), snewn() and sresize() for the
malloc functions, which automatically cast to the same type they're
allocating the size of. Should prevent any future errors involving
mallocing the size of the wrong structure type, and will also make
life easier if we ever need to turn the PuTTY core code from real C
into C++-friendly C. I haven't touched the Mac frontend in this
checkin because I couldn't compile or test it.

[originally from svn r3014]
2003-03-29 16:14:26 +00:00
Simon Tatham 4756c15fc9 Yet more global-removal. The static variables in logging.c are now
absent, and also (I think) all the frontend request functions (such
as request_resize) take a context pointer, so that multiple windows
can be handled sensibly. I wouldn't swear to this, but I _think_
that only leaves the Unicode stuff as the last stubborn holdout.

[originally from svn r2147]
2002-10-26 12:58:13 +00:00
Simon Tatham ae2599845c Fix major memory leak in sftp_cmd_ls (thanks to Hans-Juergen Petrich
for pointing it out).

[originally from svn r1612]
2002-03-31 16:26:13 +00:00
Simon Tatham 0b61ac21c2 Memory leak fix: repair endemic failure to call sftp_pkt_free().
[originally from svn r1570]
2002-03-01 13:16:25 +00:00
Simon Tatham 211bad80f0 Remove ghastly hack involving fxp_error_message.
[originally from svn r1484]
2001-12-14 10:12:53 +00:00
Simon Tatham 382ffaf026 Fix error handling in sftp (the sftp_recv return value was being
checked for NULL almost nowhere).

[originally from svn r1472]
2001-12-11 20:08:12 +00:00
Simon Tatham f176cbe70f Yikes! sftp.c wasn't using the misc.h wrappered malloc functions,
meaning that PSFTP couldn't meaningfully be debugged using
Minefield. That's what I get for developing it under Unix and
forgetting to port it properly :-/

[originally from svn r1383]
2001-11-14 12:58:42 +00:00
Simon Tatham ff9a038cdd PSCP now uses the modern SFTP protocol if it can, and falls back to
scp1 if it can't. Currently not very tested - I checked it in as
soon as it completed a successful recursive copy in both directions.
Also, one known bug: you can't specify a remote wildcard, because by
the nature of SFTP we'll need to implement the wildcard engine on
the client side. I do intend to do this (and use the same wildcard
engine in PSFTP as well) but I haven't got round to it yet.

[originally from svn r1208]
2001-08-26 18:32:28 +00:00
Simon Tatham 9c5951ed35 More upgrades to psftp: it now supports mv, chmod, reget and reput.
[originally from svn r1203]
2001-08-26 11:35:11 +00:00
Simon Tatham 4a0fb28883 Patch to PSFTP: implement mkdir, rmdir, rm and scripting. Still to
do: wildcards, chmod, mv, probably other things.

[originally from svn r1168]
2001-08-04 14:19:51 +00:00
Simon Tatham 3730ada5ce Run entire source base through GNU indent to tidy up the varying
coding styles of the various contributors! Woohoo!

[originally from svn r1098]
2001-05-06 14:35:20 +00:00
Simon Tatham 6b58ab6ad4 Fix various trivial compiler warnings
[originally from svn r983]
2001-03-05 17:31:36 +00:00
Simon Tatham 2b8ab6082f Patches to prevent a couple of silly crashes
[originally from svn r954]
2001-02-27 09:11:42 +00:00
Simon Tatham 39cf689fd6 psftp now works as part of the PuTTY suite
[originally from svn r940]
2001-02-24 16:08:56 +00:00
Simon Tatham 094dd30d95 SFTP client now successfully handles cd, ls, get and put.
[originally from svn r939]
2001-02-24 12:02:35 +00:00
Simon Tatham 48b988b439 First stab at an SFTP client. Currently a Unixland testing app, not
integrated into PuTTY.

[originally from svn r938]
2001-02-23 18:21:44 +00:00