1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 18:07:59 +00:00
Commit Graph

3949 Commits

Author SHA1 Message Date
Simon Tatham
d9ccf044be Fix a collection of calls to tell_user so that they don't add their
own newline before the one tell_user puts on the end anyway. Also,
while I'm here, make up my mind about whether to prefix messages with
"scp:" or "pscp:" - I choose the latter.

[originally from svn r9914]
2013-07-11 17:24:47 +00:00
Simon Tatham
f78c9165a1 Fix a couple of code paths on which, if fxp_readdir returned an error,
we would return without first closing the directory handle we had used
as an argument.

[originally from svn r9913]
2013-07-11 17:24:44 +00:00
Simon Tatham
779466f0b0 It's not actually legal by the C standard to call qsort with a null
array pointer, _even_ if you're asking it to sort zero elements so
that in principle it should never dereference that pointer. Fix the
four instances in PSCP/PSFTP where this was previously occurring.

[originally from svn r9912]
2013-07-11 17:24:39 +00:00
Simon Tatham
84fed5c620 Fixes for the tree234 unit test: break its dependencies on half of the
rest of PuTTY, and fix a couple of format string type mismatches
pointed out by gcc.

[originally from svn r9911]
2013-07-11 17:24:32 +00:00
Simon Tatham
3d69dd2071 Add missing checks in update_for_intended_size() in the font selector
code, which would have coped badly if ever asked to select the first
font in the list at a size smaller than it supported. Luckily the
first font tended to be one of the X numeric aliases (e.g. 10x20)
which was stored with size zero, so this probably didn't actually come
up for anyone, but better safe than sorry.

[originally from svn r9910]
2013-07-11 17:24:28 +00:00
Simon Tatham
5a04ae3420 Fix a pty-freeing error which caused a segfault if you attempted to
use Restart Session in a post-not-close-on-exit pterm.

[originally from svn r9909]
2013-07-11 17:24:23 +00:00
Simon Tatham
1f3901a3a2 Add some missing null checks for inst->ldisc, which were causing
segfaults if a PuTTY or pterm did not close on exit and then you
either typed something via input_method_commit_event or changed the
line editing or echo settings.

[originally from svn r9908]
2013-07-11 17:24:20 +00:00
Simon Tatham
916cd3f0cd Remove another pointless null check, this time of inst->back in the
function which has just dereferenced it to get the exit code.

[originally from svn r9907]
2013-07-11 17:24:14 +00:00
Simon Tatham
8201e7d22d Remove redundant null checks for arguments to sftp_{get,put}_file
which are (a) never NULL anyway, and (b) have already been
dereferenced by the time we make those checks so it would be too late
if they were.

[originally from svn r9906]
2013-07-11 17:24:10 +00:00
Simon Tatham
85300e0b15 Fix a mishandling of error returns from makekey() in the SSH-1 private
key loader.

[originally from svn r9905]
2013-07-11 17:24:04 +00:00
Simon Tatham
1dbdd2c43f Add another missing bounds check in the SSH-1 private key loader.
[originally from svn r9904]
2013-07-11 17:24:01 +00:00
Simon Tatham
bc2076185e Get rid of the fixed-size 'hostname' buffer in every port-forwarded
connection, and replace it with sensible dynamically allocated
storage. While I'm at it, get rid of the disgusting dual use between
storing an actual hostname and storing an incoming SOCKS request; we
now have a separate pointer variable for each.

[originally from svn r9903]
2013-07-11 17:23:56 +00:00
Simon Tatham
8b6a8b617f Add an assortment of extra safety checks.
[originally from svn r9896]
2013-07-08 22:36:04 +00:00
Simon Tatham
ac8baf4cac Move the SSH-1 servkey and hostkey variables into the coroutine state,
since there is a theoretical code path (via the crReturn loop after
asking an interactive question about a host key or crypto algorithm)
on which we can leave and return to do_ssh1_login between allocating
and freeing those keys.

(In practice it shouldn't come up anyway with any of the current
implementations of the interactive question functions, not to mention
the unlikelihood of anyone non-specialist still using SSH-1, but
better safe than sorry.)

[originally from svn r9895]
2013-07-07 14:34:37 +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
bbc9709b48 A collection of small bug fixes from Chris West, apparently spotted by
Coverity: assorted language-use goofs like freeing the wrong thing or
forgetting to initialise a string on all code paths.

[originally from svn r9889]
2013-07-01 17:56:33 +00:00
Simon Tatham
c5876a8ba2 Fallback for manual setup of GTK 1, if autoconf is run on a system
where the GTK1 detection function AM_PATH_GTK hasn't been provided by
/usr/share/aclocal/gtk.m4 or equivalent.

(Systems without gtk.m4 are becoming more common, but on the other
hand I know at least one person is still using GTK 1 PuTTY since the
0.62 release.)

[originally from svn r9868]
2013-06-15 19:58:10 +00:00
Jacob Nevins
a7611316c5 Update docs for change to UTF-8 by default, and emphasise UTF-8 more generally.
[originally from svn r9846]
2013-05-28 23:46:44 +00:00
Simon Tatham
15f1bc7cdb It's probably well past time for this: change PuTTY's default
character set configuration to UTF-8, on both Windows and Unix, and
reorganise the dropdown lists in the Translation menu so that UTF-8
appears at the top (and Unix's odd "use font encoding" is relegated to
the bottom of the list like the special-purpose oddity it is).

[originally from svn r9843]
2013-05-25 14:03:19 +00:00
Simon Tatham
4c8c5e26b9 Fix a bug in which terminal output received from the session could be
buffered in terminal.c indefinitely and only released when further
output turned up.

Arose because we suppress the call to term_out from term_data if a
drag-select is in progress, but when the drag-select ends we weren't
proactively calling term_out to release the buffered data. So if your
session generated some terminal output while you were in mid-select,
_and had stopped by the time you let go of the mouse button_, then the
output would just sit there until released by the next call to
term_data.

[originally from svn r9768]
2013-03-10 11:04:07 +00:00
Simon Tatham
a9eb51b7d4 Remove the half-hearted attempt to make the utmp helper process drop
privileges just before dying of a fatal signal. I'm not sure what I
intended it for in the first place; it certainly isn't doing its job
properly (no setgid), it's causing compiler warnings due to not
checking the setuid return code, and we can't think of any useful
purpose for it.

[originally from svn r9766]
2013-02-24 19:28:13 +00:00
Simon Tatham
74bc2635ad Don't forget to check the return values of setuid and friends.
[originally from svn r9764]
2013-02-23 21:00:29 +00:00
Simon Tatham
40ce043a97 Give a better error message if a PuTTY private key file has a version
number we don't understand. It's nicer to report 'format too new' than
'not a PuTTY key file'.

[originally from svn r9763]
2013-02-22 21:39:02 +00:00
Ben Harris
8f3cc4a9bf Add support for HMAC-SHA-256 as an SSH-2 MAC algorithm ("hmac-sha2-256")
as specified in RFC 6668.  This is not so much because I think it's 
necessary, but because scrypt uses HMAC-SHA-256 and once we've got it we 
may as well use it.

Code very closely derived from the HMAC-SHA-1 code.

Tested against OpenSSH 5.9p1 Debian-5ubuntu1.

[originally from svn r9759]
2013-02-20 23:30:55 +00:00
Ben Harris
3045a9ac8c Take advantage of PUT_32BIT_MSB_FIRST when constructing sequence numbers
to MAC.

[originally from svn r9758]
2013-02-20 22:37:34 +00:00
Simon Tatham
329087e2da Patch from Egmont Koblinger to implement two extended variants of
xterm mouse tracking, both supported by the current up-to-date xterm
(288). They take the form of two new DEC terminal modes, 1006 and
1015, which do not in themselves _enable_ mouse tracking but they
modify the escape sequences sent if mouse tracking is enabled in the
usual way.

[originally from svn r9752]
2013-01-23 22:59:17 +00:00
Simon Tatham
2ebdd3799d Adjust comments around split_into_argv() to clarify that it's not
*Windows's* command-line splitting rules we're mimicking here; it's
VC7's, and they're not the same as VC10's.

[originally from svn r9748]
2013-01-19 17:17:44 +00:00
Simon Tatham
896f9f2256 Reorganise setup_fonts_ucs so that in case of error it does nothing
and returns its error message as a string, instead of actually
printing it on standard error and exiting. Now we can preserve the
previous error behaviour when we get a nonexistent font name at
startup time, but no longer rudely terminate in mid-session if the
user configures a bogus font name in Change Settings.

[originally from svn r9745]
2013-01-13 21:59:10 +00:00
Simon Tatham
ac115f9082 Move the -I options for all our source subdirectories out of AM_CFLAGS
and into AM_CPPFLAGS. This is more conceptually sensible according to
my reading of the automake manual, and also has the specific desirable
effect that they move to the front of the command line, ahead of any
'system' type -I options that autoconf might have felt a need for.

A user reported that autoconf had added -I/usr/local/include to their
command line for the sake of a required header file, but their
/usr/local/include also turned out to include a thing called 'proxy.h'
(from libproxy, nothing to do with us) which shadowed our own proxy.h
and caused a build failure. This should fix that.

[originally from svn r9736]
2013-01-07 19:08:33 +00:00
Simon Tatham
3c443bd2a5 Update the suggested compile command in sshbn.c's test rig.
[originally from svn r9732]
2012-12-22 18:10:08 +00:00
Simon Tatham
f2bbeca400 Fix two gcc warnings about confused printf format strings in the
bignum code's test harness. Thanks to Sup Yut Sum for fixing this in
TortoisePlink and Sven Strickroth for bringing it to my attention.

[originally from svn r9731]
2012-12-22 18:09:02 +00:00
Simon Tatham
38b668648a Ronald Landheer-Cieslak points out that the various back ends which
treat all socket closures as clean exits (because the protocol doesn't
provide for transferring a process exit code) could usefully at least
treat _socket errors_ as unclean exits. Patch the Telnet, Rlogin and
Raw backends to retain that information and return INT_MAX to the
frontend.

I wasn't sure whether it was better to solve this by modifying each
affected frontend, or each affected backend. I chose the latter, but
neither is really ideal; this is the sort of thing that makes me wish
we had a piece of fixed middleware in between, independent of both
platform and protocol.

[originally from svn r9730]
2012-12-22 09:40:47 +00:00
Simon Tatham
9a7dd918da Switch round a bogus if statement I've just noticed. Both the write to
pty_utmp_helper_pipe _and_ the close of it if we're not going to write
should be conditionalised on the pipe existing, rather than just the
former!

[originally from svn r9729]
2012-12-18 09:19:04 +00:00
Simon Tatham
7c22b1d755 Patch from Brad Smith to use posix_openpt() instead of
open("/dev/ptmx"), where the former is available. Improves
portability, since at least one OS (OpenBSD) supports the POSIX pty
functions but does it via an underlying mechanism which doesn't
involving having a /dev/ptmx.

[originally from svn r9728]
2012-12-18 09:02:38 +00:00
Simon Tatham
25c45bf043 Use O_NOCTTY (if available) when opening /dev/ptmx, just in case any
OS doesn't automatically assume it.

(It would seem faintly weird to me - surely opening the master end of
a given pty is a fairly good indication that you're _not_ a process
running inside it which wants to have it available as /dev/tty! But
you never know...)

[originally from svn r9727]
2012-12-18 09:02:38 +00:00
Simon Tatham
dbcd633985 Add a bounds check in the word-by-word selection code to prevent
attempting to call lineptr() with a y-coordinate off the bottom of the
screen and triggering the dreaded 'line==NULL' message box.

This crash can only occur if the bottommost line of the screen has the
LATTR_WRAPPED flag set, which as far as I can see you can only
contrive by constructing a LATTR_WRAPPED line further up the screen
and then moving it down using an insert-line escape sequence. That's
probably why this bug has been around forever without anyone coming
across it.

[originally from svn r9726]
2012-12-17 08:40:33 +00:00
Simon Tatham
c3df7b9b15 Patch from Hideki Eiraku to make PuTTY call GetScrollInfo, so it can
use 32-bit scrollbar position data instead of being limited to the
16-bit version that comes in scrollbar messages' wParam.

[originally from svn r9720]
2012-12-04 20:53:19 +00:00
Simon Tatham
3e22c99c9a Fix another error-reporting bug, in which sk_newlistener would fail to
capture the error code if listen() returned an error, and instead pass
0 (saved from the previous successful bind) to winsock_error_string.

[originally from svn r9708]
2012-11-14 18:32:09 +00:00
Simon Tatham
06b51312c1 When manually initialising a 'struct RSAKey' due to loading an SSH1
public key but not the private half, NULL out all the CRT-optimisation
fields as well as the private exponent pointer. Otherwise segfaults -
security-harmless, but annoying - can happen in freersakey() when we
notice they aren't null and try to free them.

[originally from svn r9705]
2012-11-13 21:34:12 +00:00
Simon Tatham
69113b16b1 Add a fallback case to winsock_error_string() which makes it call
FormatMessage to get the OS's text for any error not in our own
translation table. Should eliminate the frustrating 'unknown error'.

(I haven't chosen to use FormatMessage unconditionally, because it
comes out with enormous messages along the lines of "No connection
could be made because the target machine actively refused it" in place
of "Connection refused" and I'm Unixy enough to prefer the latter.
Also, on older Windowses, Winsock error codes are in a separate API
segment and don't work with FormatMessage anyway.)

[originally from svn r9704]
2012-11-13 18:36:27 +00:00
Simon Tatham
251876b594 Windows's sk_address_is_local() was returning the wrong answers for
IPv6 addresses, because I'd mistakenly cast an ai_addr to the low-
level 'struct in6_addr' instead of the correct 'struct sockaddr_in6'.

[originally from svn r9690]
2012-10-17 20:48:07 +00:00
Simon Tatham
7c8841d881 When a proxy negotiation function is called with PROXY_CHANGE_NEW, it
should not call plug functions, because it's being called from within
new_connection(), and the state on which the plug functions depend
will not have been set up until new_connection() returns success.
Instead, we set the error string in the Proxy_Socket, which will cause
the same error message to be returned as a failure of new_connection().

[originally from svn r9689]
2012-10-16 20:15:52 +00:00
Simon Tatham
58870f60e4 If you configure Unix PuTTY to use a proxy, tell it to even proxy
localhost connections, and also enable X forwarding in such a way that
it will attempt to connect to a Unix-domain X server socket, an
assertion will fail when proxy_for_destination() tries to call
sk_getaddr(). Fix by ensuring that Unix-domain sockets are _never_
proxied, since they fundamentally can't be.

[originally from svn r9688]
2012-10-16 20:15:51 +00:00
Simon Tatham
36b8d450f0 Add timestamps to the 'SSH raw data' logging mode.
[originally from svn r9687]
2012-10-10 18:32:23 +00:00
Simon Tatham
8e56c52eaa A user points out that we should free the 'hProcess' and 'hThread'
handles returned in the PROCESS_INFORMATION structure after we call
CreateProcess.

[originally from svn r9686]
2012-10-10 18:29:16 +00:00
Simon Tatham
74902c6966 Sumudu Fernando points out that in the big r9214 destabilisation I
mistakenly rearranged the logic in an if statement in window.c, with
the effect that scroll-wheel events are no longer sent via xterm mouse
tracking. Put it back to the way it was.

[originally from svn r9679]
[r9214 == a1f3b7a358]
2012-10-02 19:31:33 +00:00
Simon Tatham
b2b54bc470 Clip the 'lines' parameter to scroll() at the size of the scroll
window. scroll() iterates that many times, so this prevents a tedious
wait if you give a very large parameter to ESC[L or ESC[M, for
example.

A side effect is that very large requests for upward scrolling in a
context that affects the scrollback will not actually wipe out the
whole scrollback: instead they push just the current lines of the
screen into the scrollback, and don't continue on to fill it up with
endless boring blank lines. I think this is likely to be more useful
in general, since it avoids wiping out lots of useful scrollback data
by mistake. I can imagine that people might have been using it
precisely _to_ wipe the scrollback in some situations, but if so then
they should use CSI 3 J instead.

[originally from svn r9677]
2012-09-23 15:36:54 +00:00
Ben Harris
c048389315 Windows PSFTP has two places that call run_timers and I'd only updated
one of them.  Correct that.

[originally from svn r9676]
2012-09-19 22:17:10 +00:00
Ben Harris
897029153f Fix indentation mess in my timing overhaul.
[originally from svn r9675]
2012-09-19 22:16:30 +00:00
Ben Harris
a3aca31b55 Fix a stupid sign bug in run_timers() that broke Windows Plink (and
should really have broken everything else too).

[originally from svn r9674]
2012-09-19 22:12:00 +00:00