]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
8 years agoUpdate version number for 0.67 release. 0.67
Simon Tatham [Mon, 29 Feb 2016 19:59:59 +0000 (19:59 +0000)]
Update version number for 0.67 release.

8 years agoRemove spurious -shareexists reference in Plink docs.
Simon Tatham [Sat, 27 Feb 2016 09:17:27 +0000 (09:17 +0000)]
Remove spurious -shareexists reference in Plink docs.

That option does exist, but only on master; it was not in the 0.66
release. It turned up by mistake when I updated the documentation copy
of the Plink online help while preparing the 0.66 release, because I
ran plink from the wrong branch.

The new release automation should stop that kind of mistake from
happening in future.

8 years agoMake get_user_sid() return the cached copy if one already exists.
Simon Tatham [Sat, 27 Feb 2016 09:25:23 +0000 (09:25 +0000)]
Make get_user_sid() return the cached copy if one already exists.

A user reported in January that locking down our process ACL causes
get_user_sid's call to OpenProcessToken to fail with a permissions
error. This _shouldn't_ be important, because we'll already have found
and cached the user SID before getting that far - but unfortunately
the call to get_user_sid in winnpc.c was bypassing the cache and
trying the whole process again.

This fix changes the memory ownership semantics of get_user_sid():
it's now an error to free the value it gives you, or else the *next*
call to get_user_sid() will return a stale pointer. Hence, also
removed those frees everywhere they appear.

8 years agoMention the new Secure Contact Key in the GPG docs appendix.
Simon Tatham [Sat, 27 Feb 2016 08:52:45 +0000 (08:52 +0000)]
Mention the new Secure Contact Key in the GPG docs appendix.

The reporter of vuln-pscp-sink-sscanf asked for a key to encrypt the
vulnerability report with, and having generated one, it seemed like a
good idea to make it part of the official PuTTY GPG key set and
publish it for the next person to use.

8 years agoTighten up pointer handling after ssh_pkt_getstring.
Simon Tatham [Mon, 29 Feb 2016 19:38:12 +0000 (19:38 +0000)]
Tighten up pointer handling after ssh_pkt_getstring.

ssh_pkt_getstring can return (NULL,0) if the input packet is too short
to contain a valid string.

In quite a few places we were passing the returned pointer,length pair
to a printf function with "%.*s" type format, which seems in practice
to have not been dereferencing the pointer but the C standard doesn't
actually guarantee that. In one place we were doing the same job by
hand with memcpy, and apparently that _can_ dereference the pointer in
practice (so a server could have caused a NULL-dereference crash by
sending an appropriately malformed "x11" type channel open request).
And also I spotted a logging call in the "forwarded-tcpip" channel
open handler which had forgotten the field width completely, so it was
erroneously relying on the string happening to be NUL-terminated in
the received packet.

I've tightened all of this up in general by normalising (NULL,0) to
("",0) before calling printf("%.*s"), and replacing the two even more
broken cases with the corrected version of that same idiom.

8 years agoFix vulnerability CVE-2016-2563 in old scp protocol.
Simon Tatham [Wed, 24 Feb 2016 20:13:10 +0000 (20:13 +0000)]
Fix vulnerability CVE-2016-2563 in old scp protocol.

There was a rogue sscanf("%s") with no field width limit, targeting a
stack-based buffer, and scanning a string containing untrusted data.
It occurs in the 'sink' side of the protocol, i.e. when downloading
files *from* the server.

Our own bug id for this vulnerability is 'vuln-pscp-sink-sscanf'.

8 years agoIt's a new year.
Jacob Nevins [Sat, 27 Feb 2016 10:38:48 +0000 (10:38 +0000)]
It's a new year.

(cherry picked from commit cfbe604d068ea8761eeb5da0138e4bef50dd077f)

8 years agoFix strict-aliasing warnings in sk_tcp_peer_info.
Colin Watson [Thu, 28 Jan 2016 21:22:07 +0000 (21:22 +0000)]
Fix strict-aliasing warnings in sk_tcp_peer_info.

GCC 6 emits strict-aliasing warnings here, so use the existing
sockaddr_union arrangements to avoid those.  As a prerequisite for being
able to express sk_tcp_peer_info in terms of sockaddr_union, I fixed up
the union elements to be a bit less odd in the NO_IPV6 case.

(cherry picked from commit c026b48c537250ac03573845ff9da6fd9f45776d)

8 years agoAvoid -Wmisleading-indentation warnings with GCC 6.
Colin Watson [Thu, 28 Jan 2016 21:19:41 +0000 (21:19 +0000)]
Avoid -Wmisleading-indentation warnings with GCC 6.

GCC 6 warns about potentially misleading indentation, such as:

    if (condition) stmt1; stmt2;

Chaining multiple ifs on a single line runs into this warning, even if
it's probably not actually misleading to a human eye, so just add a
couple of newlines to pacify the compiler.

(cherry picked from commit d700c33422926dda1b4af90bf1fcd262b03cfca8)

8 years agoFix a 64-bit-cleanness error in sshcrc's generator.
Simon Tatham [Tue, 26 Jan 2016 22:09:01 +0000 (22:09 +0000)]
Fix a 64-bit-cleanness error in sshcrc's generator.

Not that anyone actually needs to use that conditioned-out main(),
since it only generates the table already present in the same source
file, but since @ch3root's unused-variable patch touched it I tried
compiling it and noticed in passing that I'd also got the wrong printf
format directive for an unsigned long.

(cherry picked from commit 9351a5bfe4b1630227581d77f1aff4ca729ab8c1)

8 years agoRemove some unused variables.
Simon Tatham [Tue, 26 Jan 2016 18:36:26 +0000 (18:36 +0000)]
Remove some unused variables.

Thanks to @ch3root again for this patch.

(cherry picked from commit 70f641f84527fcb5a2ccbff7c8e238003ff2d2f3)

8 years agoAdd the new copy.but to .gitignore.
Simon Tatham [Tue, 22 Dec 2015 13:56:07 +0000 (13:56 +0000)]
Add the new copy.but to .gitignore.

Arrgh, _another_ one I only remember seconds too late!

(cherry picked from commit 51465fac73742602003db2c445109a3526fad16e)

8 years agoAutogenerate licence text in doc subdir from LICENCE.
Simon Tatham [Thu, 25 Feb 2016 20:45:27 +0000 (20:45 +0000)]
Autogenerate licence text in doc subdir from LICENCE.

Now we have licence.pl, it seems to me to make very good sense to have
it generate the Halibut form(s) of the licence and copyright year as
well as the source-code forms.

As a result, I believe _no_ copies of the licence text or copyright
date exist any more except for the master one in LICENCE - so I can
completely remove the checklist section about all the places to update
it, because there's only one. Hooray!

(cherry picked from commit 774d37a0dc79441d6add265a0d360af3e53f8460)

Conflicts:
doc/licence.but

(cherry-picker's note: the conflict was just because the deleted file
didn't have identical contents)

8 years agoStop copying the licence text into C source code.
Simon Tatham [Thu, 25 Feb 2016 20:43:54 +0000 (20:43 +0000)]
Stop copying the licence text into C source code.

Now all the uses of the licence text or the short copyright notice get
it from a new header "licence.h", which in turn is built by a Perl
script licence.pl invoked by mkfiles.pl, using LICENCE itself as the
source.

Hence, I can completely remove a whole section from the list of
licence locations in CHECKLST.txt :-)

(cherry picked from commit 9ddd071ec28050b3be572f25f3ae7d44e46e4039)

Conflicts:
unix/gtkdlg.c
windows/winpgnt.c

(cherry-picker's notes: one conflict was just changed context, the
other was deleting a copy of the licence that wasn't quite the same
between branches)

8 years agoUse readonly edit controls in some Windows dialogs.
Simon Tatham [Thu, 25 Feb 2016 20:42:00 +0000 (20:42 +0000)]
Use readonly edit controls in some Windows dialogs.

This makes the About and Licence boxes copy-and-pasteable, similarly
to what I've just done on Unix.

(But unlike on the Unix side, here I haven't touched the host key
prompt dialog, because that's a standard Windows MessageBox and not
easy to mess around with. Plus, in any case, you can already hit ^C to
copy the whole text out of a MessageBox. Same goes for the PGP
fingerprints dialog.)

As a side effect, several copies of the copyright notice and licence
text have moved from .rc files into C source. I've updated
CHECKLST.txt, but they won't stay there for long.

(cherry picked from commit 2eb952ca31aa13d1f6f429305fbb6f43a9a28c56)

Conflicts:
windows/pageant.rc
windows/puttygen.rc
windows/win_res.rc2

(cherry-picker's notes: the conflict was just because several copies
of the licence text were deleted, and they weren't quite the same
between branches)

8 years agoMake some static text in GTK dialogs selectable.
Simon Tatham [Thu, 25 Feb 2016 20:39:22 +0000 (20:39 +0000)]
Make some static text in GTK dialogs selectable.

I've made the licence text, the About box, and the host key dialog
into GTK selectable edit controls. (The former because it contains a
lot of text; the About box because pasting version numbers into bug
reports is obviously useful; the host key because of the fingerprint.)

(cherry picked from commit 21101c7397e460933635a7bfed813864fc4f88fe)

Conflicts:
unix/gtkdlg.c
unix/unix.h

(cherry-picker's notes: not a trivial resolution, since I had to apply
the equivalent changes in the pre-GTK3-port version of the code)

8 years agoPut back in a missing dynamic-load wrapper on SetSecurityInfo.
Simon Tatham [Sat, 28 Nov 2015 18:31:10 +0000 (18:31 +0000)]
Put back in a missing dynamic-load wrapper on SetSecurityInfo.

We had inadvertently raised the minimum supported Windows version in
the course of restricting PuTTY's ACL.

(cherry picked from commit bf3621f247937b51e983f364377bb408b4cb609b)

8 years agoCode-sign the Windows PuTTY binaries and installer.
Simon Tatham [Fri, 11 Dec 2015 06:47:20 +0000 (06:47 +0000)]
Code-sign the Windows PuTTY binaries and installer.

Or, at least, potentially do so. The build script now has a slot into
which code-signing can be dropped by setting a variable in the bob
configuration to specify an appropriate command line.

The variable will typically need to point at a script wrapping the
actual signing tool, since there are lots of fiddly details
(timestamping countersignature, certificate, private key, etc) not
given on the command lines in this build script, on the basis that
they're local configuration questions for whoever is _running_ this
build script.

(cherry picked from commit d0e9630e1c2f880bb7cb7ae107685bd1a6d189c4)

8 years agoFix a mistaken use of a format string in logevent().
Simon Tatham [Fri, 27 Nov 2015 23:55:16 +0000 (23:55 +0000)]
Fix a mistaken use of a format string in logevent().

logevent() doesn't do printf-style formatting (though the logeventf
wrapper in ssh.c does), so if you need to format a message, it has to
be done separately with dupprintf.

(cherry picked from commit 1659cf3f1455f7e3d9c97a66f90a0cfa914d1ce3)

8 years agoMove sfree inside if.
Owen Dunn [Fri, 27 Nov 2015 19:52:46 +0000 (19:52 +0000)]
Move sfree inside if.

(cherry picked from commit 0f5299e5a86e87068277b19c008ff5eb0f78d022)

8 years agoDocument UNPROTECT define that disables tightened ACL.
Owen Dunn [Tue, 24 Nov 2015 23:13:03 +0000 (23:13 +0000)]
Document UNPROTECT define that disables tightened ACL.

(cherry picked from commit 21a37d287cced473c12d23581fc1a200552ad1e0)

8 years agoSurround process protection with an #ifndef UNPROTECT
Owen Dunn [Tue, 24 Nov 2015 23:12:33 +0000 (23:12 +0000)]
Surround process protection with an #ifndef UNPROTECT

(cherry picked from commit 8b65fef55c688d8a52bd56f426e345671fab0303)

8 years agoMake our process's ACL more restrictive.
Simon Tatham [Thu, 25 Feb 2016 20:30:58 +0000 (20:30 +0000)]
Make our process's ACL more restrictive.

By default Windows processes have wide open ACLs which allow interference
by other processes running as the same user.  Adjust our ACL to make this
a bit harder.

Because it's useful to protect PuTTYtel as well, carve winsecur.c into
advapi functions and wincapi.c for crypt32 functions.

(cherry picked from commit 48db456801cf90369330248075b7e480252696ff)

Conflicts:
Recipe

(cherry-picker's note: the conflict was just some context not looking
quite the same)

8 years agoFix a memory leak in uxproxy.c.
Simon Tatham [Sun, 22 Nov 2015 15:02:14 +0000 (15:02 +0000)]
Fix a memory leak in uxproxy.c.

We set up a pair of bufchains for the standard input and output
exchanged with the proxy process, but forgot to clear them when the
Local_Proxy_Socket is cleaned up.

(cherry picked from commit bb66e9870e1d297de502767031563b8f2334cb1c)

8 years agoMove SID-getting code into a separate function so it can be shared by
Owen Dunn [Sun, 22 Nov 2015 12:04:04 +0000 (12:04 +0000)]
Move SID-getting code into a separate function so it can be shared by
make_private_security_descriptor and a new function protectprocess().

protectprocess() opens the running PuTTY process and adjusts the
Everyone and user access control entries in its ACL to deny a
selection of permissions which malicious processes running as the same
user could use to hijack PuTTY.

(cherry picked from commit aba7234bc167c8c056a9ea4f939a6dcda10e84f3)

8 years agoDocument 'Cannot assign requested address' error.
Jacob Nevins [Sat, 21 Nov 2015 12:21:31 +0000 (12:21 +0000)]
Document 'Cannot assign requested address' error.

Often it means you tried to connect to port 0.

(cherry picked from commit c4f963ebd71dd07b3c6dcade9a2a9a86a7322519)

8 years agoConvert Buildscr to use the new "do/win" mechanism.
Simon Tatham [Tue, 17 Nov 2015 18:41:52 +0000 (18:41 +0000)]
Convert Buildscr to use the new "do/win" mechanism.

(cherry picked from commit 470337d0f2591534221390f50a69f8c9f6fe0558)

8 years agoBig revision to CHECKLST.txt for release.pl and Mason.
Simon Tatham [Thu, 12 Nov 2015 19:11:07 +0000 (19:11 +0000)]
Big revision to CHECKLST.txt for release.pl and Mason.

Half the release checklist has changed recently, what with me
completely reworking the website and also writing all this release
automation. I think these are all the checklist changes needed now the
dust has settled, though of course when I do the next actual release I
expect there'll turn out to be something I missed...

(cherry picked from commit 3e811b3dff506cef03426469fc676a519d531781)

8 years agoFurther release automation.
Simon Tatham [Thu, 12 Nov 2015 19:09:36 +0000 (19:09 +0000)]
Further release automation.

I've added extra modes to release.pl which should automate the more
tedious parts of the deployment phase: uploading the release build to
all the places it needs to go, checking its integrity once it gets
there, verifying that everything can be downloaded again usefully,
checking content-types etc.

The new version should check more thoroughly (it checks the whole FTP
and HTTP download directories, so it will spot errors like failing to
update the FTP 'latest' symlink), and take fewer commands to run.

(cherry picked from commit f08e2de078b9122d4732a94cbbd81ca66cb87eed)

8 years agoFix potential segfaults in reading OpenSSH's ASN.1 key format.
Simon Tatham [Thu, 25 Feb 2016 20:26:33 +0000 (20:26 +0000)]
Fix potential segfaults in reading OpenSSH's ASN.1 key format.

The length coming back from ber_read_id_len might have overflowed, so
treat it as potentially negative. Also, while I'm here, accumulate it
inside ber_read_id_len as an unsigned, so as to avoid undefined
behaviour on integer overflow, and toint() it before return.

Thanks to Hanno Böck for spotting this, with the aid of AFL.

(cherry picked from commit 5b7833cd474a24ec098654dcba8cb9509f3bf2c1)

Conflicts:
import.c

(cherry-picker's note: resolving the conflict involved removing an
entire section of the original commit which fixed ECDSA code not
present on this branch)

8 years agoFix an out-of-bounds read in fgetline().
Simon Tatham [Tue, 10 Nov 2015 18:49:09 +0000 (18:49 +0000)]
Fix an out-of-bounds read in fgetline().

Forgot that a zero-length string might have come back from fgets.

Thanks to Hanno Böck for spotting this, with the aid of AFL.

(cherry picked from commit 5815d6a65af992881f5462097c9320f3a4716e0c)

8 years agoFix a segfault in parsing OpenSSH private key files.
Simon Tatham [Thu, 25 Feb 2016 20:22:23 +0000 (20:22 +0000)]
Fix a segfault in parsing OpenSSH private key files.

The initial test for a line ending with "PRIVATE KEY-----" failed to
take into account the possibility that the line might be shorter than
that. Fixed by introducing a new library function strendswith(), and
strstartswith() for good measure, and using that.

Thanks to Hanno Böck for spotting this, with the aid of AFL.

(cherry picked from commit fa7b23ce9025daba08e86bb934fc430099792b9a)

Conflicts:
misc.c
misc.h

(cherry-picker's note: the conflicts were only due to other functions
introduced on trunk just next to the ones introduced by this commit)

8 years agoRationalise and document log options somewhat.
Jacob Nevins [Sun, 8 Nov 2015 11:57:39 +0000 (11:57 +0000)]
Rationalise and document log options somewhat.

TOOLTYPE_NONNETWORK (i.e. pterm) already has "-log" (as does Unix
PuTTY), so there's no sense suppressing the synonym "-sessionlog".

Undocumented lacunae that remain:

plink accepts -sessionlog, but does nothing with it. Arguably it should.

puttytel accepts -sshlog/-sshrawlog (and happily logs e.g. Telnet
negotiation, as does PuTTY proper).

(cherry picked from commit a454399ec8d841e627d9d5e05ac977536e776754)

Conflicts:
unix/uxplink.c
windows/winplink.c

(cherry-picker's notes: the conflict was only contextual, in the Plink
help output)

8 years agoMore post-release checklist updates, and a new script.
Simon Tatham [Sat, 7 Nov 2015 15:59:00 +0000 (15:59 +0000)]
More post-release checklist updates, and a new script.

I've added a few sample shell commands in the upload procedure (mostly
so that I don't have to faff about remembering how rsync trailing
slashes work every time), and also written a script called
'release.pl', which automates the updating of the version number in
all the various places it needs to be done and also ensures the PSCP
and Plink transcripts in the docs will match the release itself.

(cherry picked from commit f3230c85457cc3d13c46e8ea91c9748dcd0054af)

8 years agoOne small post-release checklist tweak.
Simon Tatham [Sat, 7 Nov 2015 15:15:07 +0000 (15:15 +0000)]
One small post-release checklist tweak.

I spotted that I've been checking that old-style Windows Help files
were delivered with content-type "application/octet-stream", but not
also checking the same thing about the marginally newer .CHM ones. (Or
at least not writing it down in the wishlist; I think I did actually
check on at least one occasion.)

(cherry picked from commit 3552f37ba5eab32247e44af96fa7a41994268159)

8 years agoPost-0.66 release checklist updates.
Simon Tatham [Sat, 7 Nov 2015 10:12:00 +0000 (10:12 +0000)]
Post-0.66 release checklist updates.

The one-off reminder to finish the key rollover is now done, so I can
remove it.

(cherry picked from commit 503061e569af091b9c31f75e5e17c6f39a70f72f)

8 years agobignum_set_bit: Don't abort if asked to clear an inaccessible bit
Ben Harris [Sun, 11 Oct 2015 08:27:55 +0000 (09:27 +0100)]
bignum_set_bit: Don't abort if asked to clear an inaccessible bit

All those bits are clear anyway.

Bug found with the help of afl-fuzz.

(cherry picked from commit 4f340599029715d863b84bdfc0407f582114a23c)

8 years agoUpdate version number for 0.66 release. 0.66
Simon Tatham [Sat, 7 Nov 2015 09:08:21 +0000 (09:08 +0000)]
Update version number for 0.66 release.

8 years agoDocument the new session-logging command line options.
Simon Tatham [Sat, 7 Nov 2015 09:51:24 +0000 (09:51 +0000)]
Document the new session-logging command line options.

If I'm going to announce them as a feature in 0.66, it would be
embarrassing to forget to mention them in the documentation.

8 years agoPuTTYgen's default hasn't been 1024 bits since 0.63.
Jacob Nevins [Thu, 22 Oct 2015 00:46:28 +0000 (01:46 +0100)]
PuTTYgen's default hasn't been 1024 bits since 0.63.

(cherry picked from commit 9f9d72ec58642e91b4f93ee4405a8086ee2fb2f0)

8 years agoFix winhandl.c's failure to ever free a foreign handle.
Simon Tatham [Fri, 25 Sep 2015 15:03:47 +0000 (16:03 +0100)]
Fix winhandl.c's failure to ever free a foreign handle.

Handles managed by winhandl.c have a 'busy' flag, which is used to
mean two things: (a) is a subthread currently blocked on this handle
so various operations in the main thread have to be deferred until it
finishes? And (b) is this handle currently one that should be returned
to the main loop to be waited for?

For HT_INPUT and HT_OUTPUT, those things are either both true or both
false, so a single flag covering both of them is fine. But HT_FOREIGN
handles have the property that they should always be waited for in the
main loop, but no subthread is blocked on them. The latter means that
operations done on them in the main thread should not be deferred; the
only such operation is cleaning them up in handle_free().

handle_free() was failing to spot this, and was deferring freeing
HT_FOREIGN handles until their subthread terminated - which of course
never happened. As a result, when a named pipe server was closed, its
actual Windows event object got destroyed, but winhandl.c still kept
passing it back to the main thread, leading to a tight loop because
MsgWaitForMultipleObjects would return ERROR_INVALID_HANDLE and never
block.

(cherry picked from commit 431f8db86278836adbe63dba7d1ab25fb94b616d)

8 years agoAdd a FAQ for 'checksum mismatch' reports.
Simon Tatham [Sun, 9 Aug 2015 20:18:27 +0000 (21:18 +0100)]
Add a FAQ for 'checksum mismatch' reports.

The aim is to try to reduce the incidence of the two least helpful
classes of those reports: the ones which have just got mismatched
checksum files, and the ones which don't tell us the information that
would help.

(cherry picked from commit 8ff3b222430cea48500cabdf402efe1f459f9ae4)

8 years agoCheck the x argument to check_boundary() more carefully.
Ben Harris [Tue, 13 Oct 2015 19:33:12 +0000 (20:33 +0100)]
Check the x argument to check_boundary() more carefully.

This is a minimal fix for CVE-2015-5309, and while it's probably
unnecessary now, it seems worth committing for defence in depth and to
give downstreams something reasonably non-intrusive to cherry-pick.

8 years agoMore robust control sequence parameter handling.
Ben Harris [Wed, 7 Oct 2015 22:54:39 +0000 (23:54 +0100)]
More robust control sequence parameter handling.

Parameters are now accumulated in unsigned integers and carefully checked
for overflow (which is turned into saturation).  Things that consume them
now have explicit range checks (again, saturating) to ensure that their
inputs are sane.  This should make it much harder to cause overflow by
supplying ludicrously large numbers.

Fixes two bugs found with the help of afl-fuzz.  One of them may be
exploitable and is CVE-2015-5309.

8 years agoHandle packets with no type byte by returning SSH_MSG_UNIMPLEMENTED.
Ben Harris [Sat, 17 Oct 2015 20:00:31 +0000 (21:00 +0100)]
Handle packets with no type byte by returning SSH_MSG_UNIMPLEMENTED.

The previous assertion failure is obviously wrong, but RFC 4253 doesn't
explicitly declare them to be a protocol error.  Currently, the incoming
packet isn't logged, which might cause some confusion for log parsers.

Bug found with the help of afl-fuzz.

8 years agoWhen checking for an existing log, store the FILE * in a local variable.
Ben Harris [Sat, 17 Oct 2015 11:12:23 +0000 (12:12 +0100)]
When checking for an existing log, store the FILE * in a local variable.

It's not used outside logfopen, and leaving an infalid file pointer
lying around in the log context caused a segfault if the user
cancelled logging.

Bug found by afl-fuzz before it had even started fuzzing.

8 years agorsa2_pubkey_bits: Cope correctly with a NULL return from rsa2_newkey()
Ben Harris [Fri, 9 Oct 2015 23:58:11 +0000 (00:58 +0100)]
rsa2_pubkey_bits: Cope correctly with a NULL return from rsa2_newkey()

Dereferencing it is not correct.
Bug found with the help of afl-fuzz.

Conflicts:
sshrsa.c

8 years agoFix a format string vulnerability if MALLOC_LOG is set.
Tim Kosse [Fri, 1 May 2015 13:55:37 +0000 (15:55 +0200)]
Fix a format string vulnerability if MALLOC_LOG is set.

(cherry picked from commit e443fd3a77f8c138b458fb8759dc0747703541ac)

8 years agoFix format string vulnerabilities.
Tim Kosse [Fri, 1 May 2015 13:54:51 +0000 (15:54 +0200)]
Fix format string vulnerabilities.

Reported by Jong-Gwon Kim. Also fixes a few memory leaks in the
process.

(cherry picked from commit 6a70f944f648fedc7e866b4561372caa9091bf1a)

8 years agoSanitise bad characters in log file names.
Simon Tatham [Fri, 25 Sep 2015 08:23:26 +0000 (09:23 +0100)]
Sanitise bad characters in log file names.

On Windows, colons are illegal in filenames, because they're part of
the path syntax. But colons can appear in automatically constructed
log file names, if an IPv6 address is expanded from the &H placeholder.

Now we coerce any such illegal characters to '.', which is a bit of a
bodge but should at least cause a log file to be generated.

(cherry picked from commit 64ec5e03d5362ed036e9de1a765085c571eaa3b7)

8 years agoShout more loudly if we can't open a log file.
Simon Tatham [Fri, 25 Sep 2015 08:15:21 +0000 (09:15 +0100)]
Shout more loudly if we can't open a log file.

A user points out that logging fopen failures to the Event Log is a
bit obscure, and it's possible to proceed for months in the assumption
that your sessions are being correctly logged when in fact the
partition was full or you were aiming them at the wrong directory. Now
we produce output visibly in the PuTTY window.

(cherry picked from commit e1628105163135ca21abb6a841d109969d7979ec)

8 years agoCommand-line options to log sessions.
Simon Tatham [Thu, 24 Sep 2015 16:30:04 +0000 (17:30 +0100)]
Command-line options to log sessions.

Log files, especially SSH packet logs, are often things you want to
generate in unusual circumstances, so it's good to have lots of ways
to ask for them. Particularly, it's especially painful to have to set
up a custom saved session to get diagnostics out of the command-line
tools.

I've added options '-sessionlog', '-sshlog' and '-sshrawlog', each of
which takes a filename argument. I think the fourth option (session
output but filtered down to the printable subset) is not really a
_debugging_ log in the same sense, so it's not as critical to have an
option for it.

(cherry picked from commit 13edf90e0a4397088085cfcd53a4311319b708b4)

8 years agoFix spurious EAGAIN in Plink host key (and other) prompts.
Simon Tatham [Sat, 17 Oct 2015 16:30:53 +0000 (17:30 +0100)]
Fix spurious EAGAIN in Plink host key (and other) prompts.

Plink sets standard input into nonblocking mode, meaning that read()
from fd 0 in an interactive context will typically return -1 EAGAIN.
But the prompt functions in uxcons.c, used for verifying SSH host keys
and suchlike, were doing an unguarded read() from fd 0, and then
panicking and aborting the session when they got EAGAIN.

Fixed by inventing a wrapper around read(2) which handles EAGAIN but
passes all other errors back to the caller. (Seemed slightly less
dangerous than the stateful alternative of temporarily re-blockifying
the file descriptor.)

(cherry picked from commit bea758a7ae0507e0d4a24b370f8401661cc1a2c8)

Conflicts:
unix/uxcons.c

Cherry-picker's notes: the conflict was a trivial one. The new
function block_and_read() by this commit appears just before
verify_ssh_host_key(), which has a new prototype on the source branch,
close enough to disrupt the patch hunk's context. Easily fixed.

8 years agoKey rollover: fix the .htaccess files built by Buildscr.
Simon Tatham [Thu, 3 Sep 2015 18:04:54 +0000 (19:04 +0100)]
Key rollover: fix the .htaccess files built by Buildscr.

The build script generates the .htaccess files that go in each
individual build and redirect generic names like 'putty.tar.gz' to the
real filenames including that build's version number. Those .htaccess
files redirect the corresponding signatures as well, so they need
updating now that we're generating signature files with a different
extension.

(cherry picked from commit 6744387924835792147f73644e1eed10e146b5c8)

8 years agoKey rollover: cut and paste errors in pgpkeys.but.
Simon Tatham [Thu, 3 Sep 2015 18:04:26 +0000 (19:04 +0100)]
Key rollover: cut and paste errors in pgpkeys.but.

What should have been links to the old DSA keys were actually a second
copy of the links to the old RSA ones. Ahem.

(cherry picked from commit b62af0f40aa15c3ab79c8166c34f60f6e4192214)

8 years agoKey rollover: add a checklist item for the Download page.
Simon Tatham [Wed, 2 Sep 2015 17:39:32 +0000 (18:39 +0100)]
Key rollover: add a checklist item for the Download page.

Next time I do a release, I'll have to remember to adjust the download
page links to the GPG signature files.

(cherry picked from commit 7524da621b1689b3384020cd6d83c990ef86bfa1)

8 years agoKey rollover: put the new Master Key fingerprint in the tools.
Simon Tatham [Wed, 2 Sep 2015 17:31:24 +0000 (18:31 +0100)]
Key rollover: put the new Master Key fingerprint in the tools.

For the moment we're also retaining the old ones. Not sure when will
be the best time to get rid of those; after the next release, perhaps?

(cherry picked from commit e88b8d21f2f7a73cd9e2f21bcb408b2abebd0667)

8 years agoKey rollover: switch to signing using the new keys.
Simon Tatham [Wed, 2 Sep 2015 17:30:10 +0000 (18:30 +0100)]
Key rollover: switch to signing using the new keys.

sign.sh's command-line syntax has changed, so I've updated the sample
command line in CHECKLST as well. Also the file extensions of the
signatures have changed, so I've updated the pre-release verification
command line in CHECKLST too.

(cherry picked from commit 11eb75a260ca1c6e48a19afe241d423f6e7b0e4e)

8 years agoKey rollover: rewrite the PGP keys manual appendix.
Simon Tatham [Wed, 2 Sep 2015 17:24:39 +0000 (18:24 +0100)]
Key rollover: rewrite the PGP keys manual appendix.

This gives pride of place to the new set of keys we've recently
generated, and relegates the old ones to an afterthought.

(cherry picked from commit bb68baf53bacfc71bb0144780cf0b2b63bd76f98)

8 years agopterm: set IUTF8 on pty devices depending on charset.
Simon Tatham [Tue, 1 Sep 2015 17:35:38 +0000 (18:35 +0100)]
pterm: set IUTF8 on pty devices depending on charset.

In a UTF-8 pterm, it makes sense to set the IUTF8 flag (on systems
that have one) on the pty device, so that line editing will take
account of UTF-8 multibyte characters.

(cherry picked from commit 1840103c05d10ba1c45353282b4ad7f742a75b92)

8 years agoPerformance: cache character widths returned from Pango.
Simon Tatham [Sun, 23 Aug 2015 13:13:30 +0000 (14:13 +0100)]
Performance: cache character widths returned from Pango.

Profiling reveals that pterm in Pango rendering mode uses an absurd
amount of CPU when it's not even actually _drawing_ the text, because
of all the calls to pango_layout_get_pixel_extents() while
pangofont_draw_text tries to work out which characters it can safely
draw as part of a long string. Caching the results speeds things up
greatly.

(cherry picked from commit c3ef30c883e3657ff57679fb611f1f6ee6f33dba)

8 years ago'pterm --display' should set $DISPLAY inside the terminal.
Simon Tatham [Sat, 22 Aug 2015 14:05:12 +0000 (15:05 +0100)]
'pterm --display' should set $DISPLAY inside the terminal.

If you open a pterm on a different display via the --display
command-line option rather than by setting $DISPLAY, I think (and
other terminals seem to agree) that it's sensible to set $DISPLAY
anyway for processes running inside the terminal.

(cherry picked from commit dc16dd5aa4a3fb2e367bc6303963321e628594ac)

8 years agoNew formatting directive in logfile naming: &P for port number.
Simon Tatham [Sat, 8 Aug 2015 12:35:44 +0000 (13:35 +0100)]
New formatting directive in logfile naming: &P for port number.

Users have requested this from time to time, for distinguishing log
file names when there's more than one SSH server running on different
ports of the same host. Since we do take account of that possibility
in other areas (e.g. we cache host keys indexed by (host,port) rather
than just host), it doesn't seem unreasonable to do so here too.

(cherry picked from commit 0550943b51c538400e31ce18483032e446178120)

8 years agoWork around a failure in Windows 10 jump lists.
Simon Tatham [Thu, 6 Aug 2015 18:25:56 +0000 (19:25 +0100)]
Work around a failure in Windows 10 jump lists.

We've had several reports that launching saved sessions from the
Windows 10 jump list fails; Changyu Li reports that this is because we
create those IShellLink objects with a command line string starting
with @, and in Windows 10 that causes the SetArguments method to
silently do the wrong thing.

(cherry picked from commit 8bf5c1b31f1a1449d694e3604e293b0831eb2657)

8 years agoDon't try to load GSSAPI libs unless we'll use them.
Simon Tatham [Sat, 1 Aug 2015 21:11:16 +0000 (22:11 +0100)]
Don't try to load GSSAPI libs unless we'll use them.

A user reports that in a particular situation one of the calls to
LoadLibrary from wingss.c has unwanted side effects, and points out
that this happens even when the saved session has GSSAPI disabled. So
I've evaluated as much as possible of the condition under which we
check the results of GSS library loading, and deferred the library
loading itself until after that condition says we even care about the
results.

(cherry picked from commit 9a08d9a7c10458356b934af54206f0b642ecf715)

8 years agoHandle the VK_PACKET virtual key code.
Simon Tatham [Mon, 27 Jul 2015 19:06:02 +0000 (20:06 +0100)]
Handle the VK_PACKET virtual key code.

This is generated in response to the SendInput() Windows API call, if
that in turn is passed an KEYBDINPUT structure with KEYEVENTF_UNICODE
set. That method of input generation is used by programs such as
'WinCompose' to send an arbitrary Unicode character as if it had been
typed at the keyboard, even if the keyboard doesn't actually provide a
key for it.

Like VK_PROCESSKEY, this key code is an exception to our usual policy
of manually translating keystrokes: we handle it by calling
TranslateMessage, to get back the Unicode character it contains as a
WM_CHAR message.

(If that Unicode character in turn is outside the BMP, it may come
back as a pair of WM_CHARs in succession containing UTF-16 surrogates;
if so, that's OK, because the new Unicode WM_CHAR handler can cope.)

(cherry picked from commit 65f3500906c38ee3cf66cc75a015058e5bc6e56d)

8 years agoTurn the Windows PuTTY main window into a Unicode window.
Simon Tatham [Mon, 27 Jul 2015 19:06:02 +0000 (20:06 +0100)]
Turn the Windows PuTTY main window into a Unicode window.

This causes WM_CHAR messages sent to us to have a wParam containing a
16-bit value encoded in UTF-16, rather than an 8-bit value encoded in
the system code page.

As far as I can tell, there aren't many other knock-on effects - e.g.
you can still interact with the window using ordinary char-based API
functions such as SetWindowText, and the Windows API will do the
necessary conversions behind the scenes. However, even so, I'm half
expecting some sort of unforeseen bug to show up as a result of this.

(cherry picked from commit 67e5ceb9a8e6bc20fa0e0cf82ee9f89582e94112)

8 years agoNew centralised helper function dup_mb_to_wc().
Simon Tatham [Mon, 27 Jul 2015 19:06:02 +0000 (20:06 +0100)]
New centralised helper function dup_mb_to_wc().

PuTTY's main mb_to_wc() function is all very well for embedding in
fiddly data pipelines, but for the simple job of turning a C string
into a C wide string, really I want something much more like
dupprintf. So here is one.

I've had to put it in a new separate source file miscucs.c rather than
throwing it into misc.c, because misc.c is linked into tools that
don't also include a module providing the internal Unicode API (winucs
or uxucs). The new miscucs.c appears only in Unicode-using tools.

(cherry picked from commit 7762d7122609207059cf5cf58fb2b9c2de98dd36)

8 years agoPost-0.65 release checklist updates.
Simon Tatham [Sat, 25 Jul 2015 10:28:32 +0000 (11:28 +0100)]
Post-0.65 release checklist updates.

The -F option is no longer needed to bob in this situation; that
hasn't been the directory I keep release announcements in for a long
time; the Docs page needs adjusting for pre-release retirement as well
as the Downloads page.

(cherry picked from commit 9bea08a298580c98889834cbaffe289301753989)

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)