]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
8 years agoBump version number for 0.65 release. 0.65
Simon Tatham [Sat, 25 Jul 2015 09:54:57 +0000 (10:54 +0100)]
Bump version number for 0.65 release.

8 years agoWhen PSFTP exits in batch mode due to a command failure, set exit status != 0.
Ben Harris [Thu, 25 Jun 2015 22:27:16 +0000 (23:27 +0100)]
When PSFTP exits in batch mode due to a command failure, set exit status != 0.

There are possibly other circumstances when PSFTP should also return
failure, but that one seems particularly obvious.

8 years agoFix a crash when connection-sharing during userauth.
Simon Tatham [Mon, 22 Jun 2015 18:37:27 +0000 (19:37 +0100)]
Fix a crash when connection-sharing during userauth.

If a sharing downstream disconnected while we were still in userauth
(probably by deliberate user action, since such a downstream would
have just been sitting there waiting for upstream to be ready for it)
then we could crash by attempting to count234(ssh->channels) before
the ssh->channels tree had been set up in the first place.

A simple null-pointer check fixes it. Thanks to Antti Seppanen for the
report.

8 years agoFix a mismerge in kex null-pointer checks.
Simon Tatham [Mon, 22 Jun 2015 18:36:57 +0000 (19:36 +0100)]
Fix a mismerge in kex null-pointer checks.

I removed a vital line of code while fixing the merge conflicts when
cherry-picking 1eb578a488a71284d6b18e46df301e54805f2c35 as
26fe1e26c0f7ab42440332882295667d4a0ac500, causing Diffie-Hellman key
exchange to be completely broken because the server's host key was
never constructed to verify the signature with. Reinstate it.

8 years agoFix accidental dependence on Windows API quirk in config box.
Simon Tatham [Thu, 18 Jun 2015 06:05:19 +0000 (07:05 +0100)]
Fix accidental dependence on Windows API quirk in config box.

Our config boxes are constructed using the CreateDialog() API
function, rather than the modal DialogBox(). CreateDialog() is not
that different from CreateWindow(), so windows created with it don't
appear on the screen automatically; MSDN says that they must be shown
via ShowWindow(), just like non-dialog windows have to be. But we
weren't doing that at any point!

So how was our config box ever getting displayed at all? Apparently by
sheer chance, it turns out. The handler for a selection change in the
tree view, which has to delete a whole panel of controls and creates a
different set, surrounds that procedure with some WM_SETREDRAW calls
and an InvalidateRect(), to prevent flicker while lots of changes were
being made. And the creation of the _first_ panelful of controls, at
dialog box setup, was done by simply selecting an item in the treeview
and expecting that handler to be recursively called. And it appears
that calling WM_SETREDRAW(TRUE) and then InvalidateRect was
undocumentedly having an effect equivalent to the ShowWindow() we
should have called, so that we never noticed the latter was missing.

But a recent Vista update (all reports implicate KB3057839) has caused
that not to work any more: on an updated Vista machine, in some
desktop configurations, it seems that any attempt to fiddle with
WM_SETREDRAW during dialog setup can leave the dialog box in a really
unhelpful invisible state - the window is _physically there_ (you can
see its taskbar entry, and the mouse pointer changes as you move over
where its edit boxes are), but 100% transparent.

So now we're doing something a bit more sensible. The first panelful
of controls is created directly by the WM_INITDIALOG handler, rather
than recursing into code that wasn't really designed to run at setup
time. To be on the safe side, that handler for treeview selection
change is also disabled until the WM_INITDIALOG handler has finished
(like we already did with the WM_COMMAND handler), so that we can be
sure of not accidentally messing about with WM_SETREDRAW at all during
setup. And at the end of setup, we show the window in the sensible
way, by a docs-approved call to ShowWindow().

This appears (on the one machine I've so far tested it on) to fix the
Vista invisible-window issue, and also it should be more API-compliant
and hence safer in future.

(cherry picked from commit 6163710f043fb58fc80f6b45c14a92f7036bde75)

8 years agoAdd missing null-pointer checks in key exchange.
Simon Tatham [Sat, 13 Jun 2015 14:22:03 +0000 (15:22 +0100)]
Add missing null-pointer checks in key exchange.

Assorted calls to ssh_pkt_getstring in handling the later parts of key
exchange (post-KEXINIT) were not checked for NULL afterwards, so that
a variety of badly formatted key exchange packets would cause a crash
rather than a sensible error message.

None of these is an exploitable vulnerability - the server can only
force a clean null-deref crash, not an access to actually interesting
memory.

Thanks to '3unnym00n' for pointing out one of these, causing me to
find all the rest of them too.

(cherry picked from commit 1eb578a488a71284d6b18e46df301e54805f2c35)

Conflicts:
ssh.c

Cherry-picker's notes: the main conflict arose because the original
commit also made fixes to the ECDH branch of the big key exchange if
statement, which doesn't exist on this branch. Also there was a minor
and purely textual conflict, when an error check was added right next
to a function call that had acquired an extra parameter on master.

8 years agoUse 64-bit BignumInt wherever __uint128_t is available.
Simon Tatham [Mon, 8 Jun 2015 18:24:58 +0000 (19:24 +0100)]
Use 64-bit BignumInt wherever __uint128_t is available.

gcc and clang both provide a type called __uint128_t when compiling
for 64-bit targets, code-generated more or less similarly to the way
64-bit long longs are handled on 32-bit targets (spanning two
registers, using ADD/ADC, that sort of thing). Where this is available
(and they also provide a handy macro to make it easy to detect), we
should obviously use it, so that we can handle bignums a larger chunk
at a time and make use of the full width of the hardware's multiplier.
Preliminary benchmarking using 'testbn' suggests a factor of about 2.5
improvement.

I've added the new possibility to the ifdefs in sshbn.h, and also
re-run contrib/make1305.py to generate a set of variants of the
poly1305 arithmetic for the new size of BignumInt.

(cherry picked from commit f8b27925eee6a37df107a7cd2e718e997a52516e)

Conflicts:
sshccp.c

Cherry-picker's notes: the conflict arose because the original commit
also added new 64-bit autogenerated forms of dedicated Poly1305
arithmetic, which doesn't exist on this branch.

8 years agoImprove integer-type hygiene in bignum code.
Simon Tatham [Mon, 8 Jun 2015 18:23:48 +0000 (19:23 +0100)]
Improve integer-type hygiene in bignum code.

In many places I was using an 'unsigned int', or an implicit int by
virtue of writing an undecorated integer literal, where what was
really wanted was a BignumInt. In particular, this substitution breaks
in any situation where BignumInt is _larger_ than unsigned - which it
is shortly about to be.

(cherry picked from commit e28b35b0a39de28fa2f71aa78071d1ad62deaceb)

Conflicts:
sshbn.c
sshccp.c

Cherry-picker's notes: the conflicts were because the original commit
also modified new code (sshccp.c for dedicated Poly1305 arithmetic
routines, sshbn.c for a few bignum functions introduced on trunk for
various pieces of new crypto) which doesn't exist on this branch.

8 years agoProvide a stub random_byte() to make 'testbn' compile again.
Simon Tatham [Mon, 8 Jun 2015 18:22:55 +0000 (19:22 +0100)]
Provide a stub random_byte() to make 'testbn' compile again.

The function bignum_random_in_range() is new to sshbn.c since I last
tried to run the bignum test code.

(cherry picked from commit 0aa92c8fa2bee2e4c0082adcc9f06ead24989698)

8 years agoDon't try sending on sharing channels.
Simon Tatham [Sun, 7 Jun 2015 20:14:09 +0000 (21:14 +0100)]
Don't try sending on sharing channels.

The final main loop in do_ssh2_authconn will sometimes loop over all
currently open channels calling ssh2_try_send_and_unthrottle. If the
channel is a sharing one, however, that will reference fields of the
channel structure like 'remwindow', which were never initialised in
the first place (thanks, valgrind). Fix by excluding CHAN_SHARING
channels from that loop.

(cherry picked from commit 7366fde1d4831dcc701bc31e9de1113636fba1c5)

8 years agoClean up downstream sockets when upstream loses its SSH connection.
Simon Tatham [Sun, 7 Jun 2015 20:09:41 +0000 (21:09 +0100)]
Clean up downstream sockets when upstream loses its SSH connection.

If the real SSH connection goes away and we call sharestate_free with
downstreams still active, then that in turn calls share_connstate_free
on all those downstreams, freeing the things their sockets are using
as Plugs but not actually closing the sockets, so further data coming
in from downstream gives rise to a use-after-free bug.

(Thanks to Timothe Litt for a great deal of help debugging this.)

(cherry picked from commit 0b2f283622603242d8bce295e42342649aebbb97)

8 years agoMove BignumInt definitions into a header file.
Simon Tatham [Sat, 6 Jun 2015 13:52:29 +0000 (14:52 +0100)]
Move BignumInt definitions into a header file.

This allows files other than sshbn.c to work with the primitives
necessary to build multi-word arithmetic functions satisfying all of
PuTTY's portability constraints.

(cherry picked from commit 2c60070aad2d959a9e7e850523352c23c6aa7009)

Cherry-picker's notes: required on this branch because it's a
dependency of f8b27925eee6a37df107a7cd2e718e997a52516e which we want.

8 years agoCommit my replacement Windows I-beam mouse pointer.
Simon Tatham [Thu, 28 May 2015 17:14:14 +0000 (18:14 +0100)]
Commit my replacement Windows I-beam mouse pointer.

Installing this systemwide as the Windows text selection cursor is a
workaround for 'black-pointer'. It's a white I-beam with a one-pixel
black outline around it, so it should be visible on any background
colour. (I suppose that a backdrop of tightly packed I-beams looking
just like it might successfully hide it, but that's unlikely :-)

I constructed this some years ago for personal use; I needed it again
this week and had to go and recover it from a backup of a defunct
system, which made me think I really ought to check it in somewhere,
and this 'contrib' directory seems like the ideal place.

(cherry picked from commit e222db14ff28482b668baf7c21bb415f29e6df58)

8 years agoFix a compile warning with -DDEBUG.
Simon Tatham [Mon, 18 May 2015 20:17:21 +0000 (21:17 +0100)]
Fix a compile warning with -DDEBUG.

An unguarded write() in the dputs function caused gcc -Werror to fail
to compile. I'm confused that this hasn't bitten me before, though -
obviously normal builds of PuTTY condition out the faulty code, but
_surely_ this can't be the first time I've enabled the developer
diagnostics since gcc started complaining about unchecked syscall
returns!

(cherry picked from commit 35fde00fd1fdc084a78dc3e4c3f94dbf16bbd236)

8 years agoLog the client process ID for Windows named pipes too.
Simon Tatham [Mon, 18 May 2015 15:00:13 +0000 (16:00 +0100)]
Log the client process ID for Windows named pipes too.

Turns out it didn't take much googling to find the right API function.

(cherry picked from commit 5fc4bbf59d420af5019dc086e558e18454eab6b5)

8 years agoLog identifying information for the other end of connections.
Simon Tatham [Mon, 18 May 2015 12:57:45 +0000 (13:57 +0100)]
Log identifying information for the other end of connections.

When anyone connects to a PuTTY tool's listening socket - whether it's
a user of a local->remote port forwarding, a connection-sharing
downstream or a client of Pageant - we'd like to log as much
information as we can find out about where the connection came from.

To that end, I've implemented a function sk_peer_info() in the socket
abstraction, which returns a freeform text string as best it can (or
NULL, if it can't get anything at all) describing the thing at the
other end of the connection. For TCP connections, this is done using
getpeername() to get an IP address and port in the obvious way; for
Unix-domain sockets, we attempt SO_PEERCRED (conditionalised on some
moderately hairy autoconfery) to get the pid and owner of the peer. I
haven't implemented anything for Windows named pipes, but I will if I
hear of anything useful.

(cherry picked from commit c8f83979a368d10e8def1796cdadd7f8f3bebf74)

Conflicts:
pageant.c

Cherry-picker's notes: the conflict was because the original commit
also added a use of the same feature in the centralised Pageant code,
which doesn't exist on this branch. Also I had to remove 'const' from
the type of the second parameter to wrap_send_port_open(), since this
branch hasn't had the same extensive const-fixing as master.

8 years agoCompletely remove the privdata mechanism in dialog.h.
Simon Tatham [Fri, 8 May 2015 18:04:16 +0000 (19:04 +0100)]
Completely remove the privdata mechanism in dialog.h.

The last use of it, to store the contents of the saved session name
edit box, was removed nearly two years ago in svn r9923 and replaced
by ctrl_alloc_with_free. The mechanism has been unused ever since
then, and I suspect any further uses of it would be a bad idea for the
same reasons, so let's get rid of it.

(cherry picked from commit 42c592c4ef024af30af91241f651f699d6dbff0b)

8 years agoFix two small memory leaks in config mechanism.
Simon Tatham [Fri, 8 May 2015 17:57:18 +0000 (18:57 +0100)]
Fix two small memory leaks in config mechanism.

The memory dangling off ssd->sesslist should be freed when ssd itself
goes away, and the font settings ctrlset we delete in gtkcfg.c should
be freed as well once it's been removed from its containing array.

Thanks to Ranjini Aravind for pointing these out.

(cherry picked from commit f4956a1f9dc66973c1a9c9196ef893412b2545d7)

8 years agoProvide a script to regenerate the Blowfish init tables.
Simon Tatham [Mon, 27 Apr 2015 19:48:29 +0000 (20:48 +0100)]
Provide a script to regenerate the Blowfish init tables.

Since I've recently published a program that can easily generate the
required digits of pi, and since I was messing around in sshblowf.c
already, it seemed like a good idea to provide a derivation of all
that hex data.

(cherry picked from commit 2968563180ae5013976123d8c5106a6c394b96a6)

8 years agoPaste error in comment.
Simon Tatham [Mon, 27 Apr 2015 05:54:21 +0000 (06:54 +0100)]
Paste error in comment.

SSH2_MSG_KEX_DH_GEX_REQUEST_OLD and SSH2_MSG_KEX_DH_GEX_REQUEST were
correctly _defined_ as different numbers, but the comments to the
right containing the hex representations of their values were
accidentally the same.

(cherry picked from commit a8658edb17a462da32499752810bd6c989159500)

8 years agoAdd smemclrs of all hash states we destroy.
Simon Tatham [Sun, 26 Apr 2015 22:55:33 +0000 (23:55 +0100)]
Add smemclrs of all hash states we destroy.

(cherry picked from commit 16c46ecdaf71e4c9dddcd933778f02d78425f6a5)

Conflicts:
sshsh512.c

Cherry-picker's notes: the conflict was because the original commit
also added smemclrs to SHA384_Simple and the ssh_hash structures for
SHA-384 and SHA-512, none of which exists on this branch so those
changes are irrelevant.

8 years agoUse a timing-safe memory compare to verify MACs.
Simon Tatham [Sun, 26 Apr 2015 22:31:11 +0000 (23:31 +0100)]
Use a timing-safe memory compare to verify MACs.

Now that we have modes in which the MAC verification happens before
any other crypto operation and hence will be the only thing seen by an
attacker, it seems like about time we got round to doing it in a
cautious way that tries to prevent the attacker from using our memcmp
as a timing oracle.

So, here's an smemeq() function which has the semantics of !memcmp but
attempts to run in time dependent only on the length parameter. All
the MAC implementations now use this in place of !memcmp to verify the
MAC on input data.

(cherry picked from commit 9d5a16402168f82ba1bd695c3e95bb4812ccd0a9)

Cherry-picker's notes: the above commit comment isn't really true on
this branch, since the ETM packet protocol changes haven't been
cherry-picked. But it seemed silly to deliberately leave out even a
small safety measure.

8 years agoFix a few memory leaks.
Simon Tatham [Sun, 26 Apr 2015 09:49:24 +0000 (10:49 +0100)]
Fix a few memory leaks.

Patch due to Chris Staite.

(cherry picked from commit 78989c97c94ef45b7081d80df1c35f2cc1edfea0)

8 years agoDivide the Bugs panel in half.
Simon Tatham [Sat, 25 Apr 2015 09:46:56 +0000 (10:46 +0100)]
Divide the Bugs panel in half.

It overflowed as a result of the previous commit.

(cherry picked from commit 84e239dd88245cd3308de987b2b0fd6637b2db34)

8 years agoSupport RFC 4419.
Simon Tatham [Sat, 25 Apr 2015 09:46:53 +0000 (10:46 +0100)]
Support RFC 4419.

PuTTY now uses the updated version of Diffie-Hellman group exchange,
except for a few old OpenSSH versions which Darren Tucker reports only
support the old version.

FIXME: this needs further work because the Bugs config panel has now
overflowed.

(cherry picked from commit 62a1bce7cb3ecb98feb57c7f1fd5d55845ce1533)

8 years agoOld Dropbear servers have the ssh-close-vs-request bug.
Jacob Nevins [Thu, 23 Apr 2015 22:42:45 +0000 (23:42 +0100)]
Old Dropbear servers have the ssh-close-vs-request bug.

Add automatic bug detection. (Versions verified by Matt Johnston.)

(cherry picked from commit 63dddfc00f4ca44f8cc0a372b419e0ff45008ea2)

8 years agoFix a dangerous cross-thread memory access.
Simon Tatham [Tue, 7 Apr 2015 21:17:08 +0000 (22:17 +0100)]
Fix a dangerous cross-thread memory access.

When a winhandl.c input thread returns EOF to the main thread, the
latter might immediately delete the input thread's context. I
carefully wrote in a comment that in that case we had to not touch ctx
ever again after signalling to the main thread - but the test for
whether that was true, which also touched ctx, itself came _after_ the
SetEvent which sent that signal. Ahem.

Spotted by Minefield, which it looks as if I haven't run for a while.

(cherry picked from commit 9fec2e773873e28f1409f5e1eefaf03483070050)

8 years agoClean up a stale foreign handle in winnps.c.
Simon Tatham [Tue, 7 Apr 2015 20:54:41 +0000 (21:54 +0100)]
Clean up a stale foreign handle in winnps.c.

I had set up an event object for signalling incoming connections to
the named pipe, and then called handle_add_foreign_event to get that
event object watched for connections - but when I closed down the
listening pipe, I deleted the event object without also cancelling
that foreign-event handle, so that winhandl.c would potentially call
the callback for a destroyed object.

(cherry picked from commit 6f241cef2c9770abf71349dd59547b3e5b4c0301)

8 years agoDon't output negative numbers in the ESC[13t report.
Simon Tatham [Sat, 7 Mar 2015 20:57:26 +0000 (20:57 +0000)]
Don't output negative numbers in the ESC[13t report.

A minus sign is illegal at that position in a control sequence, so if
ESC[13t should report something like ESC[3;-123;234t then we won't
accept it as input. Switch to printing the numbers as unsigned, so
that negative window coordinates are output as their 32-bit two's
complement; experimentation suggests that PuTTY does accept that on
input.

(cherry picked from commit 2422b18a0f4d758f0660503b068dd19d92de4906)

8 years agoStop Windows PuTTY becoming unresponsive if server floods us.
Simon Tatham [Sat, 7 Mar 2015 17:10:36 +0000 (17:10 +0000)]
Stop Windows PuTTY becoming unresponsive if server floods us.

This was an old bug, fixed around 0.59, which apparently regressed
when I rewrote the main event loop using the toplevel_callback
mechanism.

Investigation just now suggests that it has to do with my faulty
assumption that Windows PeekMessage would deliver messages in its
message queue in FIFO order (i.e. that the thing calling itself a
message queue is actually a _queue_). In fact my WM_NETEVENT seems to
like to jump the queue, so that once a steady stream of them starts
arriving, we never do anything else in the main event loop (except
deal with handles).

Worked around in a simple and slightly bodgy way, namely, we don't
stop looping on PeekMessage and run our toplevel callbacks until we've
either run out of messages completely or else seen at least one that
_isn't_ a WM_NETEVENT. That way we should reliably interleave NETEVENT
processing with processing of other stuff.

(cherry picked from commit 7d97c2a8fdb745905fd61a9ce4abbf822e167cef)

8 years agoMove kh2reg.py link from svn to git.
Jacob Nevins [Sun, 1 Mar 2015 12:27:27 +0000 (12:27 +0000)]
Move kh2reg.py link from svn to git.

(cherry picked from commit 06d2fb5b372ff076d5e339f5baa3d919cb48870f)

8 years agoAdd a new checklist item.
Simon Tatham [Sat, 28 Feb 2015 15:47:45 +0000 (15:47 +0000)]
Add a new checklist item.

I managed to build from completely the wrong commit this morning, so
make sure to double-check next time!

(cherry picked from commit 45e89ed7ca42628d0fc85cd4f7fb3efebcd38614)

8 years agoTypo.
Simon Tatham [Sat, 28 Feb 2015 13:10:55 +0000 (13:10 +0000)]
Typo.

(cherry picked from commit ac27a1468962895d64ebf6d45a74a03b2afa4050)

8 years agoReorganise the release checklist.
Simon Tatham [Sat, 28 Feb 2015 12:04:54 +0000 (12:04 +0000)]
Reorganise the release checklist.

Mostly I'm rearranging things because of the new workflows that git
makes available - it's now possible (and indeed sensible) to prepare a
lot of stuff in a fairly relaxed manner in local checkouts, and then
the process of going live with the release has a lot less manual
writing of stuff and a lot more mechanical 'git push' and running of
update scripts.

However, there's one new item that was actually missed off the
previous checklist: turning off nightly pre-release builds after
making the release they were a pre-release of. Ahem.

(cherry picked from commit 8af53d1b692e6cb3aea05789d1b925fbc397453c)

8 years agoNew 'contrib' tool: a script for faking initial KEX.
Simon Tatham [Sat, 28 Feb 2015 07:58:29 +0000 (07:58 +0000)]
New 'contrib' tool: a script for faking initial KEX.

encodelib.py is a Python library which implements some handy SSH-2
encoding primitives; samplekex.py uses that to fabricate the start of
an SSH connection, up to the point where key exchange totally fails
its crypto.

The idea is that you adapt samplekex.py to construct initial-kex
sequences with particular properties, in order to test robustness and
security fixes that affect the initial-kex sequence. For example, I
used an adaptation of this to test the Diffie-Hellman range check
that's just gone into 0.64.

(cherry picked from commit 12d5b00d62240d1875be4ac0a6c5d29240696c89)

8 years agoImprove comments in winhandl.c.
Simon Tatham [Sat, 7 Feb 2015 11:48:49 +0000 (11:48 +0000)]
Improve comments in winhandl.c.

To understand the handle leak bug that I fixed in git commit
7549f2da40d3666f2c9527d84d9ed5468e231691, I had to think fairly hard
to remind myself what all this code was doing, which means the
comments weren't good enough. Expanded and rewritten some of them in
the hope that things will be clearer next time.

(cherry picked from commit a87a14ae0fc7d4621b5b1fafdb2053b3638b4b2b)

Cherry-picker's notes: this apparently pointless commit is required on
this branch because it's a dependency of the rather less pointless
9fec2e773873e28f1409f5e1eefaf03483070050.

9 years agoBump version number for 0.64 release. 0.64
Simon Tatham [Fri, 27 Feb 2015 22:42:03 +0000 (22:42 +0000)]
Bump version number for 0.64 release.

9 years agoAdd some missing smemclrs and sfrees.
Simon Tatham [Thu, 19 Feb 2015 20:08:18 +0000 (20:08 +0000)]
Add some missing smemclrs and sfrees.

The absence of these could have prevented sensitive private key
information from being properly cleared out of memory that PuTTY tools
had finished with.

Thanks to Patrick Coleman for spotting this and sending a patch.

9 years agoFix an erroneous length field in SSH-1 key load.
Simon Tatham [Thu, 19 Feb 2015 20:05:10 +0000 (20:05 +0000)]
Fix an erroneous length field in SSH-1 key load.

We incremented buf by a few bytes, so we must decrement the
corresponding length by the same amount, or else makekey() could
overrun.

Thanks to Patrick Coleman for the patch.

9 years agoEnforce acceptable range for Diffie-Hellman server value.
Simon Tatham [Thu, 5 Feb 2015 19:39:17 +0000 (19:39 +0000)]
Enforce acceptable range for Diffie-Hellman server value.

Florent Daigniere of Matta points out that RFC 4253 actually
_requires_ us to refuse to accept out-of-range values, though it isn't
completely clear to me why this should be a MUST on the receiving end.

Matta considers this to be a security vulnerability, on the grounds
that if a server should accidentally send an obviously useless value
such as 1 then we will fail to reject it and agree a key that an
eavesdropper could also figure out. Their id for this vulnerability is
MATTA-2015-002.

9 years agoRefresh the Windows installer README.txt.
Jacob Nevins [Fri, 27 Feb 2015 09:26:47 +0000 (09:26 +0000)]
Refresh the Windows installer README.txt.

The most recent version of Windows it acknowledged was XP.

9 years agoMake kh2reg.py compatible with modern Python.
Jacob Nevins [Tue, 24 Feb 2015 10:30:18 +0000 (10:30 +0000)]
Make kh2reg.py compatible with modern Python.

Bare string exceptions aren't supported any more.
Patch by Will Aoki, plus a backward compatibility tweak from Colin Watson.
Seen working with Python 2.4.3 and 2.7.6.

9 years agoMark handles defunct before calling gotdata/sentdata.
Simon Tatham [Sat, 7 Feb 2015 12:39:47 +0000 (12:39 +0000)]
Mark handles defunct before calling gotdata/sentdata.

If (say) a read handle returns EOF, and its gotdata function responds
by calling handle_free(), then we want the handle to have already had
its defunct flag set so that the handle can be destroyed. Otherwise
handle_free will set the 'done' flag to ask the subthread to
terminate, and then sit and wait for it to say it's done so -
forgetting that it signalled termination already by returning EOF, and
hence will not be responding to that signal.

Ditto for write errors on write handles, though that should happen
less often.

9 years agoFix handle leak in winhandl.c.
Simon Tatham [Sat, 7 Feb 2015 11:48:19 +0000 (11:48 +0000)]
Fix handle leak in winhandl.c.

The code for cleaning up handle structures works by the main thread
asking the per-handle subthread to shut down by means of setting its
'done' flag, and then once the subthread signals back through its
event object that it's done so, the main thread frees all its
resources and removes the event object from the list of things being
checked in the program's event loop.

But read threads were not sending back that final event acknowledging
a request to shut down, so their event objects were never being
cleaned up.

Bug spotted by Ronald Weiss.

9 years agoRemove user-key-oriented advice from host key docs.
Jacob Nevins [Sun, 18 Jan 2015 14:44:45 +0000 (14:44 +0000)]
Remove user-key-oriented advice from host key docs.

It would be rare to have a host keypair in .ppk format or on a client
machine to load into PuTTYgen, and it might confuse people into thinking
they are required to do so.

9 years agoUse local username consistently in Unix Plink.
Jacob Nevins [Mon, 5 Jan 2015 23:41:43 +0000 (23:41 +0000)]
Use local username consistently in Unix Plink.

It tries to use the local username as the remote username if it has no
better ideas, but the presence of Default Settings would defeat this,
even if it had no username set. Reported by Jonathan Amery.

9 years agoFix a copy-and-pasted comment.
Jacob Nevins [Mon, 5 Jan 2015 23:41:24 +0000 (23:41 +0000)]
Fix a copy-and-pasted comment.

9 years agoIt's a new year.
Jacob Nevins [Mon, 5 Jan 2015 23:48:01 +0000 (23:48 +0000)]
It's a new year.

9 years agoFix a handle leak in Windows PSFTP.
Simon Tatham [Sat, 20 Dec 2014 18:42:22 +0000 (18:42 +0000)]
Fix a handle leak in Windows PSFTP.

We were checking the return value of CreateThread for validity, but
not keeping it to free afterwards if it _was_ valid. Also, we weren't
closing ctx->event in the valid case either. Patch due to Tim Kosse.

9 years agoAdd a missing freeaddrinfo() in Unix sk_newlistener.
Simon Tatham [Sat, 20 Dec 2014 16:54:28 +0000 (16:54 +0000)]
Add a missing freeaddrinfo() in Unix sk_newlistener.

If we use getaddrinfo to translate the source IP address into a
sockaddr, then we need to freeaddrinfo the returned data later. Patch
due to Tim Kosse.

9 years agoClose the remote file handle if sftp_put_file's fstat fails.
Simon Tatham [Sat, 20 Dec 2014 16:53:01 +0000 (16:53 +0000)]
Close the remote file handle if sftp_put_file's fstat fails.

Instead of abruptly returning from sftp_put_file in that situation, we
now send an FXP_CLOSE instead. Patch due to Tim Kosse.

9 years agoStop referring to Plink as "PuTTY Link".
Simon Tatham [Sat, 22 Nov 2014 16:38:01 +0000 (16:38 +0000)]
Stop referring to Plink as "PuTTY Link".

I don't think anyone has ever actually called it that, colloquially
_or_ formally, and if anyone ever did (in a bug report, say) I'd
probably have to stop and think to work out what they meant. It's
universally called Plink, and should be officially so as well :-)

9 years agoAnother missing initialisation.
Simon Tatham [Sat, 22 Nov 2014 16:35:54 +0000 (16:35 +0000)]
Another missing initialisation.

This one spotted in the old-fashioned way, by actually attempting a
Plink raw connection and wondering why it didn't seem to be reading
from standard input! Turns out 'bufsize' is uninitialised until the
first send, which can inhibit any stdin reading if it gets a large
enough nonsense value.

9 years agoConsistently use &def for %makefile_extra pieces.
Simon Tatham [Sat, 22 Nov 2014 16:30:29 +0000 (16:30 +0000)]
Consistently use &def for %makefile_extra pieces.

mkfiles.pl was giving a couple of annoying perl warnings, because some
makefile_extra strings were never set by Recipe. We already have the
&def function to convert undefs into "" for this reason, but weren't
using it everywhere. Now I think we are.

9 years agoAdd some missing initialisations.
Simon Tatham [Sat, 22 Nov 2014 14:57:06 +0000 (14:57 +0000)]
Add some missing initialisations.

Spotted by valgrind, after I was testing all the Coverity bug fixes :-)

9 years agoDon't reject _and_ accept X forwarding requests!
Simon Tatham [Sat, 22 Nov 2014 09:59:37 +0000 (09:59 +0000)]
Don't reject _and_ accept X forwarding requests!

If a sharing downstream asks for an auth method we don't understand,
we should send them CHANNEL_FAILURE *and then stop processing*. Ahem.

(Spotted while examining this code in the course of Coverity-related
fixes, but not itself a Coverity-found problem.)

9 years agoFix assorted memory leaks.
Simon Tatham [Sat, 22 Nov 2014 09:58:15 +0000 (09:58 +0000)]
Fix assorted memory leaks.

All spotted by Coverity.

9 years agoFix uninitialised variable in two Windows event loops.
Simon Tatham [Sat, 22 Nov 2014 10:18:16 +0000 (10:18 +0000)]
Fix uninitialised variable in two Windows event loops.

If (Msg)WaitForMultipleObjects returns WAIT_TIMEOUT, we expect 'next'
to have been initialised. This can occur without having called
run_timers(), if a toplevel callback was pending, so we can't expect
run_timers to have reliably initialised 'next'.

I'm not actually convinced this could have come up in either of the
affected programs (Windows PSFTP and Plink), due to the list of things
toplevel callbacks are currently used for, but it certainly wants
fixing anyway for the future.

Spotted by Coverity.

9 years agoClarify when ldisc->term may be NULL.
Simon Tatham [Sat, 22 Nov 2014 10:37:14 +0000 (10:37 +0000)]
Clarify when ldisc->term may be NULL.

Namely, any ldisc that you send actual data through should have a
terminal attached, because the ldisc editing/echoing system is
designed entirely for use with a terminal. The only time you can have
an ldisc with no terminal is when it's only ever used by the backend
to report changes to the front end in edit/echo status, e.g. by Unix
Plink.

Coverity spotted an oddity in ldisc_send which after a while I decided
would never have actually caused a problem, but OTOH I agree that it
was confusing, so now hopefully it's less so.

9 years agoFix typo in validate_manual_hostkey().
Simon Tatham [Sat, 22 Nov 2014 10:12:47 +0000 (10:12 +0000)]
Fix typo in validate_manual_hostkey().

'p += strcspn' returns p always non-NULL and sometimes pointing at \0,
as opposed to 'p = strchr' which returns p sometimes non-NULL and
never pointing at \0. Test the pointer after the call accordingly.
Thanks, Coverity.

9 years agoShut down connshare upstream along with the SSH connection.
Simon Tatham [Mon, 10 Nov 2014 18:29:00 +0000 (18:29 +0000)]
Shut down connshare upstream along with the SSH connection.

This ought to happen in ssh_do_close alongside the code that shuts
down other local listening things like port forwardings, for the same
obvious reason. In particular, we should get through this _before_ we
put up a modal dialog box telling the user what just went wrong with
the SSH connection, so that further sessions started while that box is
active don't try futilely to connect to the not-really-listening
zombie upstream.

9 years agoFree copied Conf in log_free().
Jacob Nevins [Sun, 9 Nov 2014 00:54:35 +0000 (00:54 +0000)]
Free copied Conf in log_free().

Thanks to Corey Stup for pointing it out.

9 years agoDisable some mid-session configs for downstreams.
Jacob Nevins [Sun, 9 Nov 2014 00:10:46 +0000 (00:10 +0000)]
Disable some mid-session configs for downstreams.

Compression, encryption, and key exchange settings are all meaningless
to reconfigure in connection-sharing downstreams.

9 years agoDisable manual host key config in mid-session.
Jacob Nevins [Sun, 9 Nov 2014 00:08:36 +0000 (00:08 +0000)]
Disable manual host key config in mid-session.

Changing it can't have any useful effect, since we have strictly
enforced that the host key used for rekeys is the same as the first key
exchange since b8e668c.

9 years agoDocument IPv6 literal syntax for tunnels.
Jacob Nevins [Sat, 8 Nov 2014 23:37:59 +0000 (23:37 +0000)]
Document IPv6 literal syntax for tunnels.

9 years agoFix a double-free in the Gtk event log.
Jacob Nevins [Sat, 8 Nov 2014 22:22:34 +0000 (22:22 +0000)]
Fix a double-free in the Gtk event log.

It could occur some time after a line was selected in the event log
window.

9 years agoDiscourage SSH-1 in documentation.
Jacob Nevins [Sat, 8 Nov 2014 18:37:43 +0000 (18:37 +0000)]
Discourage SSH-1 in documentation.

9 years agoDon't try SSH-1 by default.
Jacob Nevins [Sat, 8 Nov 2014 18:37:00 +0000 (18:37 +0000)]
Don't try SSH-1 by default.

9 years agoTweak SSH protocol version refusal messages.
Jacob Nevins [Sat, 8 Nov 2014 18:35:31 +0000 (18:35 +0000)]
Tweak SSH protocol version refusal messages.

"required by user" will grate if the user did not configure the
behaviour (and I'm about to change the default to `2 only').

9 years agoCross-reference 'logical host' and host key config docs.
Jacob Nevins [Sat, 8 Nov 2014 18:34:24 +0000 (18:34 +0000)]
Cross-reference 'logical host' and host key config docs.

9 years agoTweak key file config docs re Pageant.
Jacob Nevins [Sat, 8 Nov 2014 18:32:31 +0000 (18:32 +0000)]
Tweak key file config docs re Pageant.

Clarify that it's not necessary to faff around with explicit key
configuration if you're using Pageant.

9 years agoRearrange SSH bug docs to match the GUI.
Jacob Nevins [Sat, 8 Nov 2014 18:31:15 +0000 (18:31 +0000)]
Rearrange SSH bug docs to match the GUI.

No change to the text.

9 years agoClarify that port forwarding is of TCP connections.
Jacob Nevins [Sat, 8 Nov 2014 18:30:01 +0000 (18:30 +0000)]
Clarify that port forwarding is of TCP connections.

(Rather than just the generic 'network connections'.)

9 years agoRefer to X11 'graphical applications'.
Jacob Nevins [Sat, 8 Nov 2014 18:29:08 +0000 (18:29 +0000)]
Refer to X11 'graphical applications'.

For people who know they need graphical applications but don't know what
X11 is.

9 years agoCorrect default lines of scrollback in the docs.
Jacob Nevins [Sat, 8 Nov 2014 17:12:24 +0000 (17:12 +0000)]
Correct default lines of scrollback in the docs.

The default was increased in fd266a3 (just before 0.63).

9 years agoUse a shorter name for the channel close bug.
Jacob Nevins [Tue, 4 Nov 2014 18:35:36 +0000 (18:35 +0000)]
Use a shorter name for the channel close bug.

The old name was too long for the Windows configuration dialog, so the
last word got lost.

9 years agoFix definition of surrogate macros.
Jacob Nevins [Mon, 3 Nov 2014 23:09:18 +0000 (23:09 +0000)]
Fix definition of surrogate macros.

Define HIGH_SURROGATE_START etc even if IS_HIGH_SURROGATE is defined,
as they are used elsewhere too. This is necessary to build with recent
MinGW.

9 years agoAdd some missing invariants in bigdiv and bigmod.
Simon Tatham [Sat, 1 Nov 2014 19:20:51 +0000 (19:20 +0000)]
Add some missing invariants in bigdiv and bigmod.

The underlying function 'bigdivmod' does not ensure either of its
outputs is normalised, so its callers must do so.

9 years agoRemove an unused variable.
Ben Harris [Sat, 1 Nov 2014 18:43:35 +0000 (18:43 +0000)]
Remove an unused variable.

As far as I can tell, it's been unused ever since it was introduced in
2001.

9 years agoReport correct error when FormatMessage fails.
Ben Harris [Sat, 1 Nov 2014 17:43:54 +0000 (17:43 +0000)]
Report correct error when FormatMessage fails.

Previously, the original error code would be reported as having come
from FormatMessage.  Spotted by GCC [-Wformat-extra-args].

9 years agoUpdate documentation to refer to Git rather than Subversion.
Ben Harris [Sat, 1 Nov 2014 17:17:57 +0000 (17:17 +0000)]
Update documentation to refer to Git rather than Subversion.

9 years agoMove definition of SECURITY_WIN32 from makefiles into source.
Simon Tatham [Sat, 1 Nov 2014 14:44:16 +0000 (14:44 +0000)]
Move definition of SECURITY_WIN32 from makefiles into source.

This makes it easier for people to recompile the source in other
contexts or other makefiles.

9 years agoFix two double-frees in ssh2_load_userkey().
Simon Tatham [Tue, 28 Oct 2014 18:39:55 +0000 (18:39 +0000)]
Fix two double-frees in ssh2_load_userkey().

We should NULL out mac after freeing it, so that the cleanup code
doesn't try to free it again; also if the final key creation fails, we
should avoid freeing ret->comment when we're going to go to that same
cleanup code which will free 'comment' which contains the same pointer.

Thanks to Christopher Staite for pointing these out.

9 years agoUpdate the example bob command in the release checklist.
Simon Tatham [Sun, 26 Oct 2014 08:02:35 +0000 (08:02 +0000)]
Update the example bob command in the release checklist.

Building from a git tag requires a different command-line syntax from
a Subversion tag.

9 years agoAdd a .gitignore, now this project is in git.
Simon Tatham [Sat, 25 Oct 2014 14:44:35 +0000 (15:44 +0100)]
Add a .gitignore, now this project is in git.

9 years agoCross-reference the description of winadj@putty.projects.tartarus.org
Jacob Nevins [Tue, 21 Oct 2014 11:33:33 +0000 (11:33 +0000)]
Cross-reference the description of winadj@putty.projects.tartarus.org
to its bug-compatibility mode.

[originally from svn r10287]

9 years agoTurn mkunxarc.sh back into an ordinary sh script.
Simon Tatham [Wed, 1 Oct 2014 20:52:16 +0000 (20:52 +0000)]
Turn mkunxarc.sh back into an ordinary sh script.

It became bash-dependent in r9229 because I used a bashism to remove
the 'r' from the front of $SVN_REV, but that's not needed any more.

[originally from svn r10281]
[r9229 == bd60f2fc5ba21250ffb2c612397d02b109d2b24f]

9 years agoAdd a missing bounds check in the Deflate decompressor.
Simon Tatham [Wed, 1 Oct 2014 18:33:45 +0000 (18:33 +0000)]
Add a missing bounds check in the Deflate decompressor.

The symbol alphabet used for encoding ranges of backward distances in
a Deflate compressed block contains 32 symbol values, but two of them
(symbols 30 and 31) have no meaning, and hence it is an encoding error
for them to appear in a compressed block. If a compressed file did so
anyway, this decompressor would index past the end of the distcodes[]
array. Oops.

This is clearly a bug, but I don't believe it's a vulnerability. The
nonsense record we load from distcodes[] in this situation contains an
indeterminate bogus value for 'extrabits' (how many more bits to read
from the input stream to complete the backward distance) and also for
the offset to add to the backward distance after that. But neither of
these can lead to a buffer overflow: if extrabits is so big that
dctx->nbits (which is capped at 32) never exceeds it, then the
decompressor will simply swallow all further data without producing
any output, and otherwise the decompressor will consume _some_ number
of spare bits from the input, work out a backward distance and an
offset in the sliding window which will be utter nonsense and probably
out of bounds, but fortunately will then AND the offset with 0x7FFF at
the last minute, which makes it safe again. So I think the worst that
a malicious compressor can do is to cause the decompressor to generate
strange data, which of course it could do anyway if it wanted to by
sending that same data legally compressed.

[originally from svn r10278]

9 years agoRework versioning system to not depend on Subversion.
Simon Tatham [Wed, 24 Sep 2014 10:33:13 +0000 (10:33 +0000)]
Rework versioning system to not depend on Subversion.

I've shifted away from using the SVN revision number as a monotonic
version identifier (replacing it in the Windows version resource with
a count of days since an arbitrary epoch), and I've removed all uses
of SVN keyword expansion (replacing them with version information
written out by Buildscr).

While I'm at it, I've done a major rewrite of the affected code which
centralises all the computation of the assorted version numbers and
strings into Buildscr, so that they're all more or less alongside each
other rather than scattered across multiple source files.

I've also retired the MD5-based manifest file system. A long time ago,
it seemed like a good idea to arrange that binaries of PuTTY would
automatically cease to identify themselves as a particular upstream
version number if any changes were made to the source code, so that if
someone made a local tweak and distributed the result then I wouldn't
get blamed for the results. Since then I've decided the whole idea is
more trouble than it's worth, so now distribution tarballs will have
version information baked in and people can just cope with that.

[originally from svn r10262]

9 years agoCorrect man page description of -hostkey to match actual behaviour.
Jacob Nevins [Tue, 23 Sep 2014 22:35:02 +0000 (22:35 +0000)]
Correct man page description of -hostkey to match actual behaviour.

[originally from svn r10235]

9 years agoBodge around the failing Coverity build in winshare.c.
Simon Tatham [Tue, 23 Sep 2014 12:38:16 +0000 (12:38 +0000)]
Bodge around the failing Coverity build in winshare.c.

The winegcc hack I use for my Coverity builds is currently using a
version of wincrypt.h that's missing a couple of constants I use.
Ensure they're defined by hand, but (just in case I defined them
_wrong_) also provide a command-line define so I can do that only in
the case of Coverity builds.

[originally from svn r10234]

9 years agoAdd some index terms for host key overrides.
Jacob Nevins [Sat, 20 Sep 2014 23:06:10 +0000 (23:06 +0000)]
Add some index terms for host key overrides.

[originally from svn r10232]

9 years agoUpdate transcripts for recent command-line help changes.
Jacob Nevins [Sat, 20 Sep 2014 22:58:48 +0000 (22:58 +0000)]
Update transcripts for recent command-line help changes.

[originally from svn r10231]

9 years agoMove -sercfg out of the "SSH only" section of command-line help.
Jacob Nevins [Sat, 20 Sep 2014 22:51:27 +0000 (22:51 +0000)]
Move -sercfg out of the "SSH only" section of command-line help.

[originally from svn r10230]

9 years agoUpdate command-line help and man pages for -hostkey.
Jacob Nevins [Sat, 20 Sep 2014 22:49:47 +0000 (22:49 +0000)]
Update command-line help and man pages for -hostkey.

[originally from svn r10229]

9 years agoDon't show SSH connection sharing options mid-session (they don't work).
Jacob Nevins [Sat, 20 Sep 2014 22:14:24 +0000 (22:14 +0000)]
Don't show SSH connection sharing options mid-session (they don't work).

[originally from svn r10228]

9 years agoFix a FIXME and a markup error in the manual host key docs.
Jacob Nevins [Tue, 9 Sep 2014 15:08:33 +0000 (15:08 +0000)]
Fix a FIXME and a markup error in the manual host key docs.

[originally from svn r10224]

9 years agoChange the naming policy for connection-sharing Unix sockets.
Simon Tatham [Tue, 9 Sep 2014 12:47:39 +0000 (12:47 +0000)]
Change the naming policy for connection-sharing Unix sockets.

I had initially assumed that, since all of a user's per-connection
subdirectories live inside a top-level putty-connshare.$USER directory
that's not accessible to anyone else, there would be no need to
obfuscate the names of the internal directories for privacy, because
nobody would be able to look at them anyway.

Unfortunately, that's not true: 'netstat -ax' run by any user will
show up the full pathnames of Unix-domain sockets, including pathname
components that you wouldn't have had the access to go and look at
directly. So the Unix connection sharing socket names do need to be
obfuscated after all.

Since Unix doesn't have Windows's CryptProtectMemory, we have to do
this manually, by creating a file of random salt data inside the
top-level putty-connshare directory (if there isn't one there already)
and then hashing that salt with the "user@host" connection identifier
to get the socket directory name. What a pain.

[originally from svn r10222]

9 years agoNew option to manually configure the expected host key(s).
Simon Tatham [Tue, 9 Sep 2014 11:46:24 +0000 (11:46 +0000)]
New option to manually configure the expected host key(s).

This option is available from the command line as '-hostkey', and is
also configurable through the GUI. When enabled, it completely
replaces all of the automated host key management: the server's host
key will be checked against the manually configured list, and the
connection will be allowed or disconnected on that basis, and the host
key store in the registry will not be either consulted or updated.

The main aim is to provide a means of automatically running Plink,
PSCP or PSFTP deep inside Windows services where HKEY_CURRENT_USER
isn't available to have stored the right host key in. But it also
permits you to specify a list of multiple host keys, which means a
second use case for the same mechanism will probably be round-robin
DNS names that select one of several servers with different host keys.

Host keys can be specified as the standard MD5 fingerprint or as an
SSH-2 base64 blob, and are canonicalised on input. (The base64 blob is
more unwieldy, especially with Windows command-line length limits, but
provides a means of specifying the _whole_ public key in case you
don't trust MD5. I haven't bothered to provide an analogous mechanism
for SSH-1, on the basis that anyone worrying about MD5 should have
stopped using SSH-1 already!)

[originally from svn r10220]

9 years agoAdd an option to suppress horizontal scroll bars in list boxes.
Simon Tatham [Tue, 9 Sep 2014 11:46:14 +0000 (11:46 +0000)]
Add an option to suppress horizontal scroll bars in list boxes.

I'm about to add a list box which expects to contain some very long
but uninformative strings, and which is also quite vertically squashed
so there's not much room for a horizontal scroll bar to appear in it.
So here's an option in the list box specification structure which
causes the constructed GTKTreeView to use the 'ellipsize' option for
all its cell renderers, i.e. too-long strings are truncated with an
ellipsis.

Windows needs no change, because its list boxes already work this way.

[originally from svn r10219]