]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
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]

9 years agoMove base64_decode_atom into misc.c.
Simon Tatham [Tue, 9 Sep 2014 11:46:10 +0000 (11:46 +0000)]
Move base64_decode_atom into misc.c.

I'm about to need to refer to it from a source file that won't
necessarily always be linked against sshpubk.c, so it needs to live
somewhere less specialist. Now it sits alongside base64_encode_atom
(already in misc.c for another reason), which is neater anyway.

[originally from svn r10218]

9 years agoHandle save/load of set-typed config items.
Simon Tatham [Tue, 9 Sep 2014 11:46:07 +0000 (11:46 +0000)]
Handle save/load of set-typed config items.

I'm about to introduce a configuration option which is really a _set_
of string values (rather than an ordered list), and I'm going to
represent it in Conf as a string->string map (since that's a data type
we already support) in which every key which exists at all maps to the
empty string.

This change modifies settings.c so that it can write out such options
into the saved session as a comma-separated list of the key strings
only, rather than the form 'string1=,string2=,string3=' which you'd
get if you just used the existing wmap().

(Reading the result back in turns out not to need a code change - the
existing code already does what we want if it's reading a list of
key=value pairs and one of them doesn't have an = sign at all.)

[originally from svn r10217]

9 years agoClose the listening socket when a sharing upstream dies.
Simon Tatham [Sun, 7 Sep 2014 13:06:52 +0000 (13:06 +0000)]
Close the listening socket when a sharing upstream dies.

Without this, doing 'Restart Session' on Windows in a session with
sharing enabled but no actual sharing being done would crash, because
the first incarnation of the session would become an upstream and
establish a listening named pipe, which then wouldn't get cleaned up
when the session closed, so the restarted session would try to connect
to it, triggering a call to plug_accepting on a freed sharestate.

[originally from svn r10216]

9 years agoCope with REG_SZ data not having a trailing NUL.
Simon Tatham [Sun, 7 Sep 2014 13:06:50 +0000 (13:06 +0000)]
Cope with REG_SZ data not having a trailing NUL.

A user points out that the person who writes a REG_SZ into the
registry can choose whether or not to NUL-terminate it properly, and
if they don't, RegQueryValueEx will retrieve it without the NUL. So if
someone does that to PuTTY's saved session data, then PuTTY may
retrieve nonsense strings.

Arguably this is the fault of whoever tampered with the saved session
data without doing it the same way we would have, but even so, there
ought to be some handling at our end other than silently returning the
wrong data, and putting the NUL back on seems more sensible than
complaining loudly.

[originally from svn r10215]

9 years agoFix null dereference in ldisc_configure.
Simon Tatham [Wed, 27 Aug 2014 22:25:37 +0000 (22:25 +0000)]
Fix null dereference in ldisc_configure.

The IDM_RECONF handler unconditionally calls ldisc_configure to
reconfigure the line discipline for the new echo/edit settings, but in
fact ldisc can be NULL if no session is currently active. (Indeed, the
very next line acknowledges this, by testing it for NULL before
calling ldisc_send!) Thanks to Alexander Wong for the report.

[originally from svn r10214]

9 years agoFix another crash at KEXINIT time, ahem.
Simon Tatham [Mon, 28 Jul 2014 17:47:36 +0000 (17:47 +0000)]
Fix another crash at KEXINIT time, ahem.

This is the same code I previously fixed for failing to check NULL
pointers coming back from ssh_pkt_getstring if the server's KEXINIT
ended early, leading to an embarrassing segfault in place of a fatal
error message. But I've now also had it pointed out to me that the
fatal error message passes the string as %s, which is inappropriate
because (being read straight out of the middle of an SSH packet) it
isn't necessarily zero-terminated!

This is still just an embarrassing segfault in place of a fatal error
message, and not exploitable as far as I can see, because the string
is passed to a dupprintf, which will either read off the end of
allocated address space and segfault non-exploitably, or else it will
find a NUL after all and carefully allocate enough space to format an
error message containing all of the previous junk. But still, how
embarrassing to have messed up the same code _twice_.

[originally from svn r10211]

9 years agoTruncate all terminal lines when we clear scrollback.
Simon Tatham [Thu, 24 Jul 2014 18:13:16 +0000 (18:13 +0000)]
Truncate all terminal lines when we clear scrollback.

Now Jacob has reminded me that 'resize-no-truncate' was already on the
wishlist, I notice that it suggested Clear Scrollback should remove
the preserved information off to the right. On the basis that that's
(at least partly) a privacy feature, that seems sensible, so let's do it.

[originally from svn r10210]

9 years agoPreserve truncated parts of terminal lines after a resize.
Simon Tatham [Wed, 23 Jul 2014 21:48:02 +0000 (21:48 +0000)]
Preserve truncated parts of terminal lines after a resize.

We now only truncate a termline to the current terminal width if we're
actually going to modify it. As a result, resizing to a narrower
terminal width and then immediately back again, with no terminal
output in between, should restore the previous screen contents. Only
lines that are actually modified while the terminal is narrow (and
scrolling them around doesn't count as modification) should now be
truncated.

This will be a bit nicer for Unix window resizing (since X lacks the
Windows distinction between mid-drag resize events and the ultimate
drag-release, so can't defer the call to term_size until the latter as
we can on Windows), but mostly it's inspired by having played with a
tiling window manager recently and hence realised that in some
environments windows will be resized back and forth without much
control as a side effect of just moving them around - so it's
generally desirable for resizes to be non-destructive.

[originally from svn r10208]

9 years agoAnother fix to timer handling.
Simon Tatham [Sun, 13 Jul 2014 07:49:29 +0000 (07:49 +0000)]
Another fix to timer handling.

Robert de Bath points out that failure to remove the timer whose
callback returned FALSE may not have been the cause of runaway timer
explosion; another possibility is that a function called from
timer_trigger()'s call to run_timers() has already set a timer up by
the time run_timers() returns, and then we set another one up on top
of it. Fix that too.

[originally from svn r10206]

9 years agoWork around a timer leak with GTK 2.4.22 on openSUSE 13.1.
Simon Tatham [Tue, 8 Jul 2014 22:22:12 +0000 (22:22 +0000)]
Work around a timer leak with GTK 2.4.22 on openSUSE 13.1.

Mihkel Ader reports that on that system, timers apparently aren't
getting auto-destroyed when timer_trigger returns FALSE, so the change
in r10181 has caused GTK PuTTY to gradually allocate more and more
timers and consume more and more CPU as they all keep firing.

As far as I can see, this must surely be a bug in GTK 2 (the docs say
that timers _are_ auto-destroyed when their callback returns false),
and it doesn't seem to happen for me with GTK 2.4.23 on Ubuntu 14.04.
However, I'll try to work around it by _explicitly_ destroying each
old timer before we zero out the variable containing its id.

[originally from svn r10202]
[r10181 == e4c4bd20920e11458ab0ec0cd17c69b8bf7f6d00]

9 years agoFix automatic version numbering in the Unix tarball.
Simon Tatham [Mon, 7 Jul 2014 19:47:23 +0000 (19:47 +0000)]
Fix automatic version numbering in the Unix tarball.

Manfred Schwarb points out that when I moved the autoconf machinery up
from the unix subdirectory to the top level, in r10141, I missed a
couple of lingering $(srcdir)/.. in the make rule for version.o, as a
result of which the automatic checking of the manifest wasn't doing
its thing and tools built from a standard .tar.gz were reporting as
'Unidentified build'.

[originally from svn r10201]
[r10141 == a947c49bec36957cb5d38e1dc2e22dc0e3465849]

9 years agoImplement this year's consensus on CHANNEL_FAILURE vs CHANNEL_CLOSE.
Simon Tatham [Sun, 6 Jul 2014 14:05:39 +0000 (14:05 +0000)]
Implement this year's consensus on CHANNEL_FAILURE vs CHANNEL_CLOSE.

We now expect that after the server has sent us CHANNEL_CLOSE, we
should not expect to see any replies to our outstanding channel
requests, and conversely after we have sent CHANNEL_CLOSE we avoid
sending any reply to channel requests from the server. This was the
consensus among implementors discussing the problem on ietf-ssh in
April 2014.

To cope with current OpenSSH's (and perhaps other servers we don't
know about yet) willingness to send request replies after
CHANNEL_CLOSE, I introduce a bug-compatibility flag which is detected
for every OpenSSH version up to and including the current 6.6 - but
not beyond, since https://bugzilla.mindrot.org/show_bug.cgi?id=1818
promises that 6.7 will also implement the new consensus behaviour.

[originally from svn r10200]

9 years agoReplace quaint references to floppies with "USB stick".
Jacob Nevins [Mon, 26 May 2014 09:27:54 +0000 (09:27 +0000)]
Replace quaint references to floppies with "USB stick".

[originally from svn r10193]

10 years agoExplicitly set the owning SID in make_private_security_descriptor.
Simon Tatham [Tue, 13 May 2014 19:19:28 +0000 (19:19 +0000)]
Explicitly set the owning SID in make_private_security_descriptor.

Philippe Maupertuis reports that on one particular machine, Windows
causes the named pipe created by upstream PuTTY to be owned by the
Administrators group SID rather than the user's SID, which defeats the
security check in the downstream PuTTY. No other machine has been
reported to do this, but nonetheless it's clearly a thing that can
sometimes happen, so we now work around it by specifying explicitly in
the security descriptor for the pipe that its owner should be the user
SID rather than any other SID we might have the right to use.

[originally from svn r10188]

10 years agoPrevent double-inclusion of ssh.h in case of -DNO_SECURITY.
Simon Tatham [Wed, 23 Apr 2014 14:05:31 +0000 (14:05 +0000)]
Prevent double-inclusion of ssh.h in case of -DNO_SECURITY.

winshare.c includes ssh.h, but if you defined NO_SECURITY it then
decides to fall back to including the stub noshare.c, which includes
ssh.h again. Fix by moving a block of includes inside the ifdef.

[originally from svn r10184]

10 years agoFix the prototype of the stub function in noshare.c.
Simon Tatham [Tue, 22 Apr 2014 17:53:50 +0000 (17:53 +0000)]
Fix the prototype of the stub function in noshare.c.

It's an old prototype from part way through the development of
connection sharing, which I must have forgotten to fix because by the
time I changed the prototype no platform was using noshare.c any more.

[originally from svn r10183]

10 years agoFix an annoying warning from GTK on Ubuntu 14.04.
Simon Tatham [Sun, 20 Apr 2014 16:48:18 +0000 (16:48 +0000)]
Fix an annoying warning from GTK on Ubuntu 14.04.

Timer objects evaporate when our timer_trigger callback is called, and
therefore we should not remember their ids beyond that time and
attempt to cancel them later. Previous versions of GTK silently
ignored us doing that, but upgrading to Ubuntu Trusty has given me a
version of GTK that complains about it, so let's stop doing it.

[originally from svn r10181]

10 years agoFix a bounds check that should have been >= not >.
Simon Tatham [Fri, 18 Apr 2014 14:37:27 +0000 (14:37 +0000)]
Fix a bounds check that should have been >= not >.

Thanks to René König for pointing it out.

[originally from svn r10174]

10 years agoAdd auto-recognition of BUG_SSH2_RSA_PADDING for ProFTPD.
Simon Tatham [Thu, 27 Mar 2014 18:07:13 +0000 (18:07 +0000)]
Add auto-recognition of BUG_SSH2_RSA_PADDING for ProFTPD.

Martin Prikryl reports that it had the exact same bug as old OpenSSH
(insisting that RSA signature integers be padded with leading zero
bytes to the same length as the RSA modulus, where in fact RFC 4253
section 6.6 says it ought to have _no_ padding), but is recently
fixed. The first version string to not have the bug is reported to be
"mod_sftp/0.9.9", so here we recognise everything less than that as
requiring our existing workaround.

[originally from svn r10161]

10 years agoNew FAQ, aimed at the people who periodically send us large
Simon Tatham [Tue, 4 Mar 2014 23:02:12 +0000 (23:02 +0000)]
New FAQ, aimed at the people who periodically send us large
questionnaires in unfriendly formats like Excel, apparently in the
mistaken belief that we have some kind of incentive to answer them. I
hope I've managed to identify the key reason why they make this
mistake.

[originally from svn r10156]

10 years agoStop using 'zip -k' to construct the Windows source archive.
Simon Tatham [Tue, 4 Mar 2014 22:56:08 +0000 (22:56 +0000)]
Stop using 'zip -k' to construct the Windows source archive.

It was intended to ensure that people still working with DOS filename
restrictions (or things approximating that, e.g. VFAT) wouldn't have
trouble. Those days are surely long gone, and now zip -k is causing
its own trouble with the new VS2010/VS2012 project files, which
include pairs of filenames that become the same under the zip -k
transformation and hence break the source archive build.

[originally from svn r10155]

10 years agoAdd 'set -e' to mksrcarc.sh, so it spots zip returning error.
Simon Tatham [Tue, 4 Mar 2014 22:56:04 +0000 (22:56 +0000)]
Add 'set -e' to mksrcarc.sh, so it spots zip returning error.

[originally from svn r10154]

10 years agoHave mksrcarc.sh log its activity to standard output.
Simon Tatham [Tue, 4 Mar 2014 22:56:03 +0000 (22:56 +0000)]
Have mksrcarc.sh log its activity to standard output.

Its previous policy of silence made sense before we did builds using
bob (gratuitous output on success caused cronmail) but now it just
makes it hard to spot problems.

[originally from svn r10153]

10 years agoAdd a missing bn_restore_invariant in RSA blinding code.
Simon Tatham [Mon, 24 Feb 2014 23:35:55 +0000 (23:35 +0000)]
Add a missing bn_restore_invariant in RSA blinding code.

We were inventing a random number by starting with a long zero bignum
and then setting bits at random, which left an opportunity for the
result to be a non-normalised representation (with a leading zero
word) and hence fail an assertion in bignum_cmp.

[originally from svn r10147]

10 years agoAdd some assertions in sshzlib.c.
Simon Tatham [Sat, 22 Feb 2014 18:02:14 +0000 (18:02 +0000)]
Add some assertions in sshzlib.c.

gcc 4.8 compiling with -O3 gives a new warning about the access to
st->pending at the top of lz77_compress, because for some reason it
thinks there's an out-of-bounds array access there (or perhaps just a
potential one, I'm not really sure which side -Warray-bounds is erring
on). Add an assertion reassuring it that st->npending can't get bigger
than the size of st->pending at the site it's complaining about, and a
second one at the site where st->npending is increased (just in case
my analysis of why it can't happen was wrong!). Also add a comment
explaining the assertions.

[originally from svn r10144]

10 years agoAdd the autogenerated empty.h to CLEANFILES.
Simon Tatham [Sat, 22 Feb 2014 18:02:10 +0000 (18:02 +0000)]
Add the autogenerated empty.h to CLEANFILES.

Colin Watson points out that it's untidy to create it with the
makefile but not clean it up again in the same way.

[originally from svn r10143]

10 years agoAdd the 'subdir-objects' option in the automake makefile.
Simon Tatham [Sat, 22 Feb 2014 18:02:06 +0000 (18:02 +0000)]
Add the 'subdir-objects' option in the automake makefile.

This rearranges the object files so that they each live alongside
their original source file, instead of all being in the same
directory. To my way of thinking this is a more or less neutral change
(perhaps marginally less tidy), but autotools is apparently beginning
to think it's the One True Way and 1.14 will give a warning if you
don't have it enabled.

[originally from svn r10142]

10 years agoMove the Unix configure script up to the top level.
Simon Tatham [Sat, 22 Feb 2014 18:01:32 +0000 (18:01 +0000)]
Move the Unix configure script up to the top level.

Previously, 'configure' and its assorted machinery lived in the 'unix'
subdir, because that seemed like a clean place to keep it given that
all the other per-platform Makefiles live in their platform
directories. However, this never sat all that happily with autotools,
and even less so now that it likes to have object file pathnames
parallel source file pathnames: if you have Makefile.am refer to
source files outside its subdir as "../terminal.c" and enable
subdir-objects then any out-of-tree build calls the corresponding
object file "../terminal.o" and so your build products mostly end up
at the directory above your build dir! And as of autotools 1.14 my
previous compensatory bodge of prefixing every source file path in
Makefile.am with "$(srcdir)" has stopped working too.

So I'm giving in to necessity, and changing policy by moving the
configure machinery up to the top level of the source tree where
autotools will be less confused by it. This should not be taken as any
indication of the primacy of the Unix port, only of the recalcitrance
of autotools.

Whereas before we had a trivial script called 'configure' at the top
level that invoked unix/configure to effectively do an 'out-of-tree
build' (for make purposes) at the top level of the source tree, we now
have a similar script in unix/configure. So this _should_ make very
little difference: people who were previously running configure from
the top level should still be able to, and likewise people who were
running it from the unix subdir.

[originally from svn r10141]

10 years agoEnable xterm mouse reporting of wheel actions in GTK.
Simon Tatham [Sun, 16 Feb 2014 16:40:46 +0000 (16:40 +0000)]
Enable xterm mouse reporting of wheel actions in GTK.

I had somehow missed this completely out of the GTK mouse-button
handling and never noticed until now!

Of course, like any other mouse action, if you want it to be handled
locally rather than passed through then you can hold down Shift.

[originally from svn r10139]

10 years agoStop sending release events for mouse wheel 'buttons' in X mouse mode.
Simon Tatham [Sun, 16 Feb 2014 16:40:45 +0000 (16:40 +0000)]
Stop sending release events for mouse wheel 'buttons' in X mouse mode.

On Windows (X mouse reporting of the mouse wheel isn't currently done
by the Unix front end, though I'm shortly about to fix that too) a
mouse wheel event is translated into a virtual button, and we send
both a press and a release of that button to terminal.c, which encodes
both in X mouse reporting escape sequences and passes them on to the
server. This isn't consistent with what xterm does - scroll-wheel
events are encoded _like_ button presses, but differ semantically in
that they don't have matching releases. So we're updating to match
xterm.

[originally from svn r10138]

10 years agoRevert half of r10135, and re-fix properly.
Simon Tatham [Wed, 5 Feb 2014 21:51:25 +0000 (21:51 +0000)]
Revert half of r10135, and re-fix properly.

One of my changes in uxnet.c was outside the NO_IPV6 ifdef, and broke
compilation in the normal mode. Revert all changes in that file and
replace with a reference to the 'step' parameter in the no-IPv6
version of the SOCKADDR_FAMILY macro, so that those warnings are
squelched anyway.

[originally from svn r10136]
[r10135 == e00a004e64d9de3f8ff5c4eb745faa326c307057]

10 years agoFix warnings when compiling with -DNO_IPV6.
Simon Tatham [Tue, 4 Feb 2014 22:37:53 +0000 (22:37 +0000)]
Fix warnings when compiling with -DNO_IPV6.

A user pointed out that 'family' was uninitialised in config.c, and
when I tried test-building with -DNO_IPV6 (and the usual -Werror, of
course) some unused variables showed up in uxnet.c too.

[originally from svn r10135]

10 years agoDon't unconditionally reset scrollback on certain escape sequences.
Simon Tatham [Sat, 25 Jan 2014 18:38:38 +0000 (18:38 +0000)]
Don't unconditionally reset scrollback on certain escape sequences.

Handlers for a number of escape sequences, notably including ESC[J and
the sequences that switch to/from the alternate screen, were
unconditionally resetting the scrollback instead of first checking the
'Reset scrollback on display activity' configuration option. I've
added the missing if statements, so now 'Reset scrollback on display
activity' should actually mean what it says.

For example, this would have inconvenienced an mplayer user, who
wouldn't be able to go up and check their scrollback while mplayer was
repeatedly redisplaying its status line, because mplayer uses ESC[J to
erase each version of the status line before printing the next
version.

[originally from svn r10125]

10 years agoFix a potential crash in ssh_setup_portfwd.
Simon Tatham [Sat, 25 Jan 2014 15:59:04 +0000 (15:59 +0000)]
Fix a potential crash in ssh_setup_portfwd.

If we search for a colon by computing ptr + host_strcspn(ptr,":"),
then the resulting pointer is always non-NULL, and the 'not found'
condition is not !p but !*p.

This typo could have caused PuTTY to overrun a string, but not in a
security-bug sense because any such string would have to have been
loaded from the configuration rather than received from a hostile
source.

[originally from svn r10123]

10 years agoSupport explicit IPv6 source addresses in Windows port forwarding.
Simon Tatham [Sat, 25 Jan 2014 15:58:59 +0000 (15:58 +0000)]
Support explicit IPv6 source addresses in Windows port forwarding.

There's been a long-standing FIXME in Windows's sk_newlistener which
says that in IPv6 mode, an explicit source address (e.g. from a
command-line option of the form -L srcaddr:12345:dest:22) is ignored.
Now it's honoured if possible.

[originally from svn r10122]

10 years agoAvoid misidentifying unbracketed IPv6 literals as host:port.
Simon Tatham [Sat, 25 Jan 2014 15:58:57 +0000 (15:58 +0000)]
Avoid misidentifying unbracketed IPv6 literals as host:port.

Both GUI PuTTY front ends have a piece of logic whereby a string is
interpreted as host:port if there's _one_ colon in it, but if there's
more than one colon then it's assumed to be an IPv6 literal with no
trailing port number. This permits the PuTTY command line to take
strings such as 'host', 'host:22' or '[::1]:22', but also cope with a
bare v6 literal such as '::1'.

This logic is also required in the two Plink front ends and in the
processing of CONF_loghost for host key indexing in ssh.c, but was
missing in all those places. Add it.

[originally from svn r10121]