]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
7 years agoShow the git commit hash in local dev builds too.
Simon Tatham [Sat, 21 Jan 2017 14:57:31 +0000 (14:57 +0000)]
Show the git commit hash in local dev builds too.

This is perhaps the more useful end of the mechanism I added in the
previous commit: now, when a developer runs a configure+make build
from a git checkout (rather than from a bob-built source tarball), the
Makefile will automatically run 'git rev-parse HEAD' and embed the
result in the binaries.

So now when I want to deploy my own bleeding-edge code for day-to-day
use on my own machine, I can easily check whether I've done it right
(e.g. did I install to the right prefix?), and also easily check
whether any given PuTTY or pterm has been restarted since I rolled out
a new version.

In order to arrange this (and in particular to force version.o to be
rebuilt when _any_ source file changes), I've had to reintroduce some
of the slightly painful Makefile nastiness that I removed in 4d8782e74
when I retired the 'manifest' system, namely having version.o depend
on a file empty.h, which in turn is trivially rebuilt by a custom make
rule whose dependencies include $(allsources). That's a bit
unfortunate, but I think acceptable: the main horribleness of the
manifest system was not that part, but the actual _manifests_, which
were there to arrange that if you modified the sources in a
distribution tarball the binaries would automatically switch to
reporting themselves as local builds rather than the version baked
into the tarball. I haven't reintroduced that part of the system: if
you check out a given git commit, modify the checked-out sources, and
build the result, the Makefile won't make any inconvenient attempts to
detect that, and the resulting build will still announce itself as the
git commit you started from.

7 years agoMake bob builds show the full source git commit hash in buildinfo.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Make bob builds show the full source git commit hash in buildinfo.

The Windows binaries, and both Windows and Unix source archives,
output from a bob build will now include the full SHA-1 of the source
git commit in their buildinfo (hence in all the About boxes and
command-line version output).

This will be occasionally useful to me at release time (there was that
one embarrassing incident where I managed not to notice that I'd made
a release build from entirely the wrong commit), but mostly, it just
seems like an obviously useful thing to put in a general buildinfo
section now that there is one.

7 years agoInclude 'build info' in all --version text and About boxes.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Include 'build info' in all --version text and About boxes.

This shows the build platform (32- vs 64-bit in particular, and also
whether Unix GTK builds were compiled with or without the X11 pieces),
what compiler was used to build the binary, and any interesting build
options that might have been set on the make command line (especially,
but not limited to, the security-damaging ones like NO_SECURITY or
UNPROTECT). This will probably be useful all over the place, but in
particular it should allow the different Windows binaries to be told
apart!

Commits 21101c739 and 2eb952ca3 laid the groundwork for this, by
allowing the various About boxes to contain free text and also
ensuring they could be copied and pasted easily as part of a bug
report.

7 years agoAdd a 'strbuf' system, for building up a large string piece by piece.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Add a 'strbuf' system, for building up a large string piece by piece.

I'm faintly surprised I haven't needed this before. Basically it's an
allocating string formatter, like dupprintf, except that it
concatenates on to the end of a previous string. You instantiate a
strbuf, then repeatedly call strbuf_catf to append pieces of formatted
output to it, and then you can extract the whole string and free it
(separately or both in one step).

7 years agoFix PE header of the VS2015 builds so they run on Windows XP.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Fix PE header of the VS2015 builds so they run on Windows XP.

By default the VS2015 linker produces binaries with the minimum
version fields in the PE header set to 06.00, which causes XP not to
recognise them as valid binaries at all. But there's no other reason
VS2015-built binaries _can't_ run on versions of Windows as old as XP;
so here I add the link option to set those fields to 05.01 which makes
XP like them again.

This only applies to the 32-bit build, because the VS2015 64-bit
linker refuses to lower the min version field to under 06.00.

7 years agoReinstate the ASLR and DEP linker flags on Windows.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Reinstate the ASLR and DEP linker flags on Windows.

Originally added in commit 0014ffb70, and promptly reverted in
6bea4b250 when we realised that VS2003 didn't actually understand
them. But now we're building with VS2015, which does understand them,
it's actually useful to put them back in again.

Looking more closely, it turns out that VS2003 didn't actually _fail
to build_ if you passed these flags on the linker command line - it
just printed a warning and ignored them. (So there was no actual need
to revert the original change, except that it would have caused
confusion.) But that means I can add them unconditionally now, without
breaking even the legacy VS2003 build.

7 years agoRemove 'putty -cleanup-during-uninstall' from legacy uninstaller.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Remove 'putty -cleanup-during-uninstall' from legacy uninstaller.

It's a bit conceptually incoherent anyway - if you're uninstalling
PuTTY _systemwide_ across a multi-user system, it doesn't really make
sense that you'd also want to wipe the saved sessions for the
individual user running the uninstaller.

Also, making this change to the Inno Setup uninstaller opens up a
nicer migration path to MSI for people doing large corporate rollouts:
they can upgrade to this version of the Inno Setup package, then do a
silent uninstall of it (which should now _actually_ be silent, since
this cleanup step was the thing that interrupted it otherwise) and
then a silent install of the MSI.

7 years agoComment that Inno Setup installer remains 32-bit only.
Simon Tatham [Sat, 21 Jan 2017 14:55:53 +0000 (14:55 +0000)]
Comment that Inno Setup installer remains 32-bit only.

Our Inno Setup installer is legacy as far as I'm concerned, so there's
no point in introducing a 64-bit version of it. 64-bit PuTTY users can
use the MSI from the start, and then there'll only ever have been one
kind of installer and they won't collide with one another.

7 years agoName the 64-bit MSI distinctively.
Simon Tatham [Sat, 21 Jan 2017 14:55:52 +0000 (14:55 +0000)]
Name the 64-bit MSI distinctively.

The 32- and 64-bit installers may be distinguishable by their pathname
in the build output directory, but it's better to have their actual
filenames be different as well, so they don't collide in people's
download directories.

7 years agoBuild an MSI installer for the new Win64 binaries.
Simon Tatham [Sat, 21 Jan 2017 14:55:52 +0000 (14:55 +0000)]
Build an MSI installer for the new Win64 binaries.

The MSI format has a fixed field for target architecture, so there's
no way to build a single MSI that can decide at install time whether
to install 32-bit or 64-bit (or both). The best you can do along those
lines, apparently, is to have two MSI files plus a bootstrap .EXE that
decides which of them to run, and as far as I'm concerned that would
just reintroduce all the same risks and annoyances that made us want
to migrate away from .EXE installers anyway.

7 years agoBuild a set of Windows 32-bit 'legacy' binaries with VS2003.
Simon Tatham [Sat, 21 Jan 2017 14:55:52 +0000 (14:55 +0000)]
Build a set of Windows 32-bit 'legacy' binaries with VS2003.

The downside of moving to VS2015 is that its output won't run on very
old versions of Windows. It's not yet clear whether anyone still cares
about things before, say, Win2000 or WinXP, but since my build
environment still _has_ VS2003 available, it's easy enough to build
the extra set of binaries anyway just in case. (At least for now.)

The new binaries live in a build output directory 'w32old'. As with
w64, there is no installer for them; but unlike w64, I don't intend to
add one.

7 years agoBuild 64-bit Windows binaries, alongside the 32-bit ones.
Simon Tatham [Sat, 21 Jan 2017 14:55:52 +0000 (14:55 +0000)]
Build 64-bit Windows binaries, alongside the 32-bit ones.

Now we've got VS2015 available (and thanks to a lot of 64-bit
cleanness fixing, in particular Tim Kosse's large patch series from
August 2015) we can do this fairly easily.

The new binaries are shipped in a 'w64' directory, alongside the
just-renamed 'w32'. There is no 64-bit installer (yet).

7 years agoSwitch the main Windows build to Visual Studio 2015.
Simon Tatham [Sat, 21 Jan 2017 14:55:48 +0000 (14:55 +0000)]
Switch the main Windows build to Visual Studio 2015.

This is a big jump from the previous VS2003. It should add a little
performance (VS2015 is a better-optimising compiler), but mostly it's
groundwork for doing other useful things such as 64-bit builds and
security-related linker features.

The downside is reduced support for very old versions of Windows,
which I'll address shortly.

7 years agoRename the 'x86' build output directory to 'w32'.
Simon Tatham [Sat, 21 Jan 2017 14:55:48 +0000 (14:55 +0000)]
Rename the 'x86' build output directory to 'w32'.

This change does affect the layout of the output build directory, and
will need corresponding website changes to avoid breaking links.

'x86' was a misnomer anyway, because it was really Windows-specific
rather than just x86-specific. Calling it 'w32' will make it look less
strange to add 'w64' alongside it.

7 years agoDo the Windows build in a subdirectory windows/build32.
Simon Tatham [Sat, 21 Jan 2017 14:55:47 +0000 (14:55 +0000)]
Do the Windows build in a subdirectory windows/build32.

Uses the BUILDDIR mechanism I added to Makefile.vc in commit
d3db17f3e.

This change is purely internal to Buildscr, and shouldn't affect the
output of a build. It paves the way to have Buildscr run multiple
Windows builds using different compilers, by putting each one in a
different subdirectory so that their outputs don't collide.

7 years agox11font: fix handling of high-bit-set SBCS characters.
Simon Tatham [Tue, 10 Jan 2017 22:22:49 +0000 (22:22 +0000)]
x11font: fix handling of high-bit-set SBCS characters.

I had mistakenly pulled a 'char' value out of a string and passed it
to x11_font_has_glyph and x11_char_struct, each of which takes its two
index bytes as int-typed parameters. But if chars are signed, that
turns high-bit-set characters into out-of-range array indices. Oops.

The range checks in x11_char_struct prevented that from causing any
problem worse than refusal to display any affected glyph. Even so,
that's not particularly helpful. Fixed by changing the index byte
parameters to unsigned char type.

7 years agoFix memory leak: Free hostkey fingerprint when cross-certifying.
Tim Kosse [Fri, 6 Jan 2017 10:44:47 +0000 (11:44 +0100)]
Fix memory leak: Free hostkey fingerprint when cross-certifying.

7 years agoAdd some missing checks for EINTR after select(2).
Simon Tatham [Fri, 6 Jan 2017 19:29:06 +0000 (19:29 +0000)]
Add some missing checks for EINTR after select(2).

I noticed today that Unix Plink responds to SIGWINCH by accidentally
dying of EINTR having interrupted its main select loop, and when I
checked, there turn out to be a couple of other select loops with the
same bug.

7 years agoRemove/rescope variable 'ret' in sftp_put_file.
Simon Tatham [Thu, 29 Dec 2016 11:25:34 +0000 (11:25 +0000)]
Remove/rescope variable 'ret' in sftp_put_file.

This is a purely stylistic cleanup - no functional change intended -
after Tim Kosse's changes in commits e9a76883a and 6f871e3d2.

I think the underlying cause of the confusion whose functional effects
he was fixing there is that I have the bad habit of tending to call
variables 'ret' for two different reasons: one is because it's holding
the value returned from some subroutine I've just called, and the
other is because it's holding the value I'm preparing to return from
the routine _containing_ the variable.

The reason it's a bad habit is that I confuse the two purposes, and a
variable of one type ends up accidentally being treated as the other.
So while Tim's commits have already fixed the functional effects of
the error in this case, this change should help prevent a recurrence
because now there's no variable called 'ret' at all that's in scope
for the whole function.

7 years agoIn random_add_noise, put the hashed noise into the pool, not the raw noise
Tim Kosse [Wed, 28 Dec 2016 14:41:40 +0000 (15:41 +0100)]
In random_add_noise, put the hashed noise into the pool, not the raw noise

random_add_noise calls SHATransform for every 64 octets of incoming noise,
yet instead of xor'ing the hashed noise into the pool it instead only xor'ed
20 octets of the raw noise in each iteration. This effectively reduced the
amount of new entropy entering the pool.

7 years agoHandle failed SSH_FXP_CLOSE requests in sftp_put_file.
Tim Kosse [Wed, 28 Dec 2016 14:34:53 +0000 (15:34 +0100)]
Handle failed SSH_FXP_CLOSE requests in sftp_put_file.

It is possible for SSH_FXP_CLOSE requests to fail. This can happen if the
server buffers writes and an error occurs flushing the data to disk while
processing the SSH_FXP_CLOSE request. If the close fails, sftp_put_file now
returns an error as well.

7 years agoFix sftp_put_file returning success on failed transfers.
Tim Kosse [Wed, 28 Dec 2016 14:27:47 +0000 (15:27 +0100)]
Fix sftp_put_file returning success on failed transfers.

Due to a shadowed variable, transfer failures were not reflected in the return
code to sftp_put_file. Instead of tracking the return code, use the 'err'
variable to decide which return code to use.

7 years agoFix sftp_get_file returning success on failed transfers.
Tim Kosse [Wed, 28 Dec 2016 13:59:49 +0000 (14:59 +0100)]
Fix sftp_get_file returning success on failed transfers.

Due to the return variable 'ret' being shadowed in the transfer loop, errors
in the transfer loop did not affect the final return value of sftp_get_file.
This particularly affects psftp's batch mode (without passing the -be
command-line argument), which would errorneously continue. The solution is
to simply remove the shadowing declaration.

7 years agoFix a compile failure with NO_IPV6.
Simon Tatham [Sun, 11 Dec 2016 22:27:40 +0000 (22:27 +0000)]
Fix a compile failure with NO_IPV6.

A user points out that buf[] in sk_tcp_peer_info is only used in the
IPv6 branch of an ifdef, and is declared with a size of
INET6_ADDRSTRLEN, which won't be defined in NO_IPV6 mode. So moving
the definition inside another IPv6-only ifdef fixes the resulting
build failure.

7 years agoFix type mismatch in sftp_find_request
Tim Kosse [Fri, 18 Nov 2016 23:34:46 +0000 (00:34 +0100)]
Fix type mismatch in sftp_find_request

The id member of the sftp_request structure is of type unsigned int.
This type is also used in the sftp_reqfind callback. In
sftp_find_request we thus need to pass a pointer to unsigned int to
find234. Before this commit, sftp_find_request was passing a pointer
to unsigned long to find234, which causes the lookup to fail on
big-endian platforms where sizeof(unsigned int) != sizeof(unsigned
long), e.g. ppc64.

7 years agoMake ESC[3J (clear scrollback) a disableable escape sequence.
Simon Tatham [Thu, 17 Nov 2016 20:25:27 +0000 (20:25 +0000)]
Make ESC[3J (clear scrollback) a disableable escape sequence.

A user complained that it was being done nonconsensually, and it seems
reasonable that the user should have the choice to prevent it.

7 years agoMake the new ^< and ^> keystrokes add the class prefix.
Simon Tatham [Wed, 16 Nov 2016 22:02:54 +0000 (22:02 +0000)]
Make the new ^< and ^> keystrokes add the class prefix.

The new font name configured by the keystrokes was missing its
"client:" or "server:" prefix, which could have led to the selection
of the wrong font in rare situations.

7 years agoUnix PuTTY/pterm: Ctrl-< / Ctrl-> to change font size.
Simon Tatham [Sun, 13 Nov 2016 13:53:42 +0000 (13:53 +0000)]
Unix PuTTY/pterm: Ctrl-< / Ctrl-> to change font size.

Each gtkfont back end now provides a routine that will return the name
of a similar font to the current one but one notch larger or smaller.
For Pango, this is just a matter of incrementing the font size field
in a standard way; for X11 server-side fonts, we have to go and do an
XListFonts query with a wildcard that requests fonts that vary only in
the size fields from the current one, and then iterate over the result
looking for the best one.

(I expect this will be more useful to Pango scalable-font users than
to X11 fonts, but it seemed a shame not to give the X11 side my best
shot while I was at it.)

Choice of hotkey: I know I'm being inconsistent with gnome-terminal's
use of Ctrl-plus and Ctrl-minus. I thought that was because I was
already using Ctrl-minus as a more convenient synonym for
Ctrl-underscore (which sends the actual control code 0x1F), but now I
actually try it, apparently I'm not. However, Ctrl-plus and Ctrl-minus
are quite horrible as a keystroke pair anyway (one has to be typed
with shift and one without!), and I feel as if the 'less' and
'greater' signs are more specific anyway, in that they specifically
indicate _size_ rather than just 'unspecified numerical value'.

7 years agogtkfont: refactor parse/unparse of XLFDs.
Simon Tatham [Sun, 13 Nov 2016 12:02:13 +0000 (12:02 +0000)]
gtkfont: refactor parse/unparse of XLFDs.

There were already two places in the code (x11font_enum_fonts and
x11_guess_derived_font_name) where we retrieved an XLFD from the X
server, sawed it up ad-hoc into its '-'-separated parts and accessed
them by numeric index.

I'm about to add a third, so before I do, let's turn this into a
somewhat principled system where we get to do the decode/encode in
just one place and call all the individual fields by names that are
actually memorable.

No functional change intended by this commit.

7 years agorelease.pl: switch the.earth.li to HTTPS.
Simon Tatham [Sun, 13 Nov 2016 11:56:09 +0000 (11:56 +0000)]
release.pl: switch the.earth.li to HTTPS.

That's the URL scheme we advertise on the website, so it's silly to do
the release-time testing by any other system.

7 years agocygtermd: be more specific in define of _XOPEN_SOURCE.
Simon Tatham [Mon, 19 Sep 2016 13:17:26 +0000 (14:17 +0100)]
cygtermd: be more specific in define of _XOPEN_SOURCE.

On Debian stretch, it seems we don't get setpgrp() unless we do not
merely define it, but define it to 500 or greater.

7 years agoAdd explicit "./" in mkfiles.pl's require statements.
Simon Tatham [Mon, 19 Sep 2016 13:13:38 +0000 (14:13 +0100)]
Add explicit "./" in mkfiles.pl's require statements.

I've just tried for the first time to run mkfiles.pl on a system where
plain 'require "sbcsgen.pl"' does not search the cwd by default.

7 years agoSetCurrentProcessExplicitAppUserModelID to fix jumplist/removable media bug
Owen Dunn [Mon, 29 Aug 2016 15:55:42 +0000 (16:55 +0100)]
SetCurrentProcessExplicitAppUserModelID to fix jumplist/removable media bug

The algorithm Windows uses to generate AppUserModelIDs "hangs on" to
removable media (CDs/DVDs) if PuTTY is launched with a CD/DVD in a drive.
Set the AppUserModelID explicitly to avoid using this algorithm.

7 years agoFix memory leak in the new make_dir_path().
Simon Tatham [Wed, 10 Aug 2016 18:34:46 +0000 (19:34 +0100)]
Fix memory leak in the new make_dir_path().

Thanks to Jason Andryuk for promptly pointing it out.

7 years agoAdded support for the XDG specification
Ondřej Lysoněk [Tue, 2 Aug 2016 13:12:43 +0000 (15:12 +0200)]
Added support for the XDG specification

The XDG configuration location ($XDG_CONFIG_HOME/putty, or
~/.config/putty) is now prefered over the old ~/.putty location, if the
XDG location already exists. If it doesn't exist, we try to use one of
the old locations ($HOME/.putty, [/etc/passwd home]/.putty, /.putty). If
none of the directories exist, we fall back to ~/.config/putty or
~/.putty, if the XDG_DEFAULT macro is defined or not, respectively. The
PUTTYDIR environment variable remains a definitive override of the
configuration location. This all ensures that the old location is still
used, unless the user explicitly requests otherwise.

The configuration directories are created using the make_dir_path()
function, to ensure that saving the configuration doesn't fail e.g.
because of a non-existent ~/.config directory.

7 years agoNew Unix utility function to make a directory path.
Simon Tatham [Sun, 7 Aug 2016 20:02:55 +0000 (21:02 +0100)]
New Unix utility function to make a directory path.

Essentially 'mkdir -p' - we try to make each prefix of the pathname,
terminating on any error other than EEXIST. Semantics are similar to
make_dir_and_check_ours(): we return NULL on success or a dynamically
allocated error message string on failure.

7 years agoLock down the search path for Windows DLL loading.
Simon Tatham [Mon, 18 Jul 2016 19:02:32 +0000 (20:02 +0100)]
Lock down the search path for Windows DLL loading.

At least on systems providing SetDefaultDllDirectories, this should
stop PuTTY from being willing to load DLLs from its containing
directory - which makes no difference when it's been properly
installed (in which case the application dir contains no DLLs anyway),
but does if it's being run from somewhere uncontrolled like a browser
downloads directory.

Preliminary testing suggests that this shouldn't break any existing
deliberate use of DLLs, including GSSAPI providers.

7 years agoclip_addchar: merge memory-management performance fix.
Simon Tatham [Mon, 27 Jun 2016 18:24:56 +0000 (19:24 +0100)]
clip_addchar: merge memory-management performance fix.

7 years agoSpeed up clipboard copies.
Jeff Westfahl [Mon, 27 Jun 2016 14:58:16 +0000 (09:58 -0500)]
Speed up clipboard copies.

Copying large scrollback buffers to the clipboard can take a long time,
up to several minutes. Doubling the size of the clipboard copy buffer
when more space is needed, instead of just adding a small constant size,
significantly speeds up clipboard copies of large scrollback buffers.

7 years agoFactor out code to close the local socket associated with a channel.
Ben Harris [Sat, 28 May 2016 13:50:02 +0000 (14:50 +0100)]
Factor out code to close the local socket associated with a channel.

The only visible effect should be that abrupt closure of an SSH
connection now leads to a slew of messages about closing forwarded
ports.

7 years agoUse ssh2_channel_got_eof() in ssh1_msg_channel_close().
Ben Harris [Wed, 25 May 2016 22:16:09 +0000 (23:16 +0100)]
Use ssh2_channel_got_eof() in ssh1_msg_channel_close().

Of course, that means renaming it to ssh_channel_got_eof().  It also
involves adding the assertions from ssh1_msg_channel_close(), just in
case.

7 years agoMove call to ssh2_channnel_check_close().
Ben Harris [Wed, 25 May 2016 22:06:20 +0000 (23:06 +0100)]
Move call to ssh2_channnel_check_close().

From ssh2_channel_got_eof() to ssh2_msg_channel_eof().  This removes
the only SSH-2 specicifity from the former.  ssh2_channel_got_eof()
can also be called from ssh2_msg_channel_close(), but that calls
ssh2_channel_check_close() already.

7 years agoAssume that u.pfd.pf and u.x11.xconn are not NULL on appropriate channels.
Ben Harris [Wed, 25 May 2016 21:22:19 +0000 (22:22 +0100)]
Assume that u.pfd.pf and u.x11.xconn are not NULL on appropriate channels.

Nothing ever sets them to NULL, and the various paths by which the
channel types can be set to CHAN_X11 or CHAN_SOCKDATA all ensure thet
the relevant union members are non-NULL.  All the removed conditionals
have been converted into assertions, just in case  I'm wrong.

7 years agoDon't completely ignore unknown types of SSH_MSG_CHANNEL_EXTENDED_DATA.
Ben Harris [Tue, 24 May 2016 21:38:40 +0000 (22:38 +0100)]
Don't completely ignore unknown types of SSH_MSG_CHANNEL_EXTENDED_DATA.

It's important to do the usual window accounting in all cases.  We
still ignore the data themselves, which I think is the right thing to
do.

7 years agoRemove CHAN_SOCKDATA_DORMANT.
Ben Harris [Mon, 23 May 2016 09:06:31 +0000 (10:06 +0100)]
Remove CHAN_SOCKDATA_DORMANT.

It's redundant with the halfopen flag and is a misuse of the channel
type field.  Happily, everything that depends on CHAN_SOCKDATA_DORMANT
also checks halfopen, so removing it is trivial.

7 years agoForward channel messages for shared channels in ssh_channel_msg().
Ben Harris [Sun, 22 May 2016 22:59:48 +0000 (23:59 +0100)]
Forward channel messages for shared channels in ssh_channel_msg().

This saves doing it separately in every function that processes such
messages.

7 years agoMore strictness in ssh_channel_msg().
Ben Harris [Sun, 22 May 2016 21:57:25 +0000 (22:57 +0100)]
More strictness in ssh_channel_msg().

Now it disconnects if the server sends
SSH_MSG_CHANNEL_OPEN_CONFIRMATION or SSH_MSG_CHANNEL_OPEN_FAILURE for
a channel that isn't half-open.  Assertions in the SSH-2 handlers for
these messages rely on this behaviour even though it's never been
enforced before.

7 years agoSwitch SSH-1 channel message handlers to use ssh_channel_msg().
Ben Harris [Sun, 22 May 2016 21:21:20 +0000 (22:21 +0100)]
Switch SSH-1 channel message handlers to use ssh_channel_msg().

This gives consistent (and stricter) handling of channel messages
directed at non-existent and half-open channels.

7 years agoGeneralise ssh2_channel_msg() to ssh_channel_msg().
Ben Harris [Sun, 22 May 2016 21:14:00 +0000 (22:14 +0100)]
Generalise ssh2_channel_msg() to ssh_channel_msg().

It now supports both SSH-1 and SSH-2 channel messages.  The SSH-1 code
doesn't yet use it, though.

7 years agoAssert that ssh2_channel_check_close() is only called in SSH-2.
Ben Harris [Sun, 22 May 2016 12:50:34 +0000 (13:50 +0100)]
Assert that ssh2_channel_check_close() is only called in SSH-2.

That really should be true, but I don't entirely trust
sshfwd_unclean_close().

7 years agoIn ssh_channel_init(), insert the new channel into the channel tree234.
Ben Harris [Sat, 21 May 2016 21:58:57 +0000 (22:58 +0100)]
In ssh_channel_init(), insert the new channel into the channel tree234.

All but one caller was doing this unconditionally.  The one conditional
call was when initialising the main channel, and in consequence PuTTY
leaked a channel structure when the server refused to open the main
channel.  Now it doesn't.

7 years agoConvert ssh2_channel_init() into ssh_channel_init().
Ben Harris [Sat, 21 May 2016 21:29:57 +0000 (22:29 +0100)]
Convert ssh2_channel_init() into ssh_channel_init().

By adding support for initialising SSH-1 channels as well.  Now all
newly-created channels go through this function.

7 years agoUnify despatch of incoming channel data between SSH-1 and SSH-2.
Ben Harris [Sat, 21 May 2016 12:13:00 +0000 (13:13 +0100)]
Unify despatch of incoming channel data between SSH-1 and SSH-2.

7 years agoDon't send SSH_MSG_CHANNEL_WINDOW_ADJUST with a zero adjustment.
Ben Harris [Tue, 17 May 2016 14:28:56 +0000 (16:28 +0200)]
Don't send SSH_MSG_CHANNEL_WINDOW_ADJUST with a zero adjustment.

7 years agoFactor out common parts of ssh_unthrottle and sshfwd_unthrottle.
Ben Harris [Tue, 17 May 2016 13:57:51 +0000 (15:57 +0200)]
Factor out common parts of ssh_unthrottle and sshfwd_unthrottle.

The SSH-2 code is essentially all shared, but SSH-1 still has some
code specific to the stdout/stderr case.

8 years agoRemove inaccurate comment about Unix getticks() function.
Ben Harris [Tue, 17 May 2016 11:07:36 +0000 (13:07 +0200)]
Remove inaccurate comment about Unix getticks() function.

It's not always based on gettimeofday(); now it mostly uses
clock_gettime().

8 years agoDocument SSH IUTF8 mode.
Jacob Nevins [Sat, 7 May 2016 10:36:23 +0000 (11:36 +0100)]
Document SSH IUTF8 mode.

8 years agoSet SSH IUTF8 appropriately in Unix Plink.
Jacob Nevins [Sat, 7 May 2016 10:35:59 +0000 (11:35 +0100)]
Set SSH IUTF8 appropriately in Unix Plink.

8 years agoFix uninitialized variable in Windows get_file_posn.
Tim Kosse [Tue, 3 May 2016 21:27:57 +0000 (23:27 +0200)]
Fix uninitialized variable in Windows get_file_posn.

The Windows implementation of get_file_posn is calling SetFilePointer
to obtain the current position in the file. However it did not
initialize the variable holding the high order 32-bit to 0. Thus,
SetFilePointer either returned -1 to indicate an error or did move the
file pointer to a different location instead of just returning the
current position. This change just initializes the variable to 0.

As a result, this bug has caused psftp's reget command to fail
resuming transfers or to create corrupt files due to setting up an
incorrect resume offset.

8 years agoRework samplekex.py to use the new -proxycmd.
Simon Tatham [Tue, 3 May 2016 15:51:42 +0000 (16:51 +0100)]
Rework samplekex.py to use the new -proxycmd.

It now expects its standard input to be connected to the same PuTTY
its standard output is talking to, i.e. expects to be invoked as a
proxy command. It conducts the same sample key exchange as it used to,
but now reads the SSH greeting and first couple of packets back from
PuTTY and minimally checks that they're something like what it was
expecting.

(In the process, I've also fixed a mistake in the Python message code
enumeration, which caused one of those expect() calls to fail.)

8 years agoAdd a '-proxycmd' command-line option.
Simon Tatham [Tue, 3 May 2016 13:31:10 +0000 (14:31 +0100)]
Add a '-proxycmd' command-line option.

This is equivalent to selecting 'Local' as the proxy type and entering
the argument string in the proxy command box, in the GUI.

I've pulled this out of all the other proxy options to promote to a
named command-line option, partly because it's the proxy option with
the most natural command-line expression in the first place (any shell
command you might want to use is already in the form of a single
string), and also because it has uses beyond end-user proxying
applications: in particular, replacing the network connection with a
local process is a convenient way to do testing in the style of
contrib/samplekex.py, avoiding the need to run a separate command to
make the test 'server' listen on a port.

8 years agoSwap endianness of the Curve25519 ECDH private key.
Simon Tatham [Tue, 3 May 2016 13:44:00 +0000 (14:44 +0100)]
Swap endianness of the Curve25519 ECDH private key.

DJB's spec at http://cr.yp.to/ecdh/curve25519-20060209.pdf is clear
that we should be clearing the low 3 bits of the _LSB_ of the private
key bit string, and setting bit 6 and clearing bit 7 of the _MSB_. We
were doing the opposite, due to feeding the resulting bit string to
bignum_from_bytes() rather than bignum_from_bytes_le().

This didn't cause an interoperability issue, because the two DH
exponentiations still commute, but it goes against the Curve25519
spec, in particular the care taken to fix the position of the leading
exponent bit.

The code is now consistent with the test vectors in RFC 7748 section
6.1: if you modify the EC_MONTGOMERY branch of ssh_ecdhkex_newkey() to
replace the loop on random_byte() with a memcpy that fills bytes[]
with 77076d0a7318a57d3c16c17251b26645df4c2f87ebc0992ab177fba51db92c2a
and then print out the resulting publicKey->x, you find that it's
(byte-reversed) the expected output value given in that RFC section,
8520f0098930a754748b7ddcb43ef75a0dbf3a0d26381af4eba4a98eaa9b4e6a.

8 years agoSend the IUTF8 terminal mode in SSH "pty-req"s.
Simon Tatham [Tue, 3 May 2016 07:43:50 +0000 (08:43 +0100)]
Send the IUTF8 terminal mode in SSH "pty-req"s.

An opcode for this was recently published in
https://tools.ietf.org/html/draft-sgtatham-secsh-iutf8-00 .

The default setting is conditional on frontend_is_utf8(), which is
consistent with the pty back end's policy for setting the same flag
locally. Of course, users can override the setting either way in the
GUI configurer, the same as all other tty modes.

8 years agoSupport frontend_is_utf8() in all front ends.
Simon Tatham [Tue, 3 May 2016 07:43:09 +0000 (08:43 +0100)]
Support frontend_is_utf8() in all front ends.

Previously only Unix front ends bothered to include it, on the basis
that only the pty backend needed it (to set IUTF8 in the pty). We're
about to need it everywhere else too.

8 years agoLoop over all _supported_, not just configured, SSH tty modes.
Simon Tatham [Mon, 2 May 2016 12:51:28 +0000 (13:51 +0100)]
Loop over all _supported_, not just configured, SSH tty modes.

Previously, the code that marshalled tty settings into the "pty-req"
request was iterating through the subkeys stored in ssh->conf, meaning
that if a session had been saved before we gained support for a
particular tty mode, the iteration wouldn't visit that mode at all and
hence wouldn't send even the default setting for it.

Now we iterate over the array of known mode identifiers in
ssh_ttymodes[] and look each one up in ssh->conf, rather than vice
versa. This means that when we add support for a new tty mode with a
nontrivial policy for choosing its default state, we should start
using the default handler immediately, rather than bizarrely waiting
for users to save a session after the change.

8 years agossh_pkt_defersend: don't call do_ssh2_transport when using SSH-1.
Ben Harris [Sun, 1 May 2016 17:16:22 +0000 (19:16 +0200)]
ssh_pkt_defersend: don't call do_ssh2_transport when using SSH-1.

Also add an assertion to do_ssh2_transport to catch this.

This bug would be highly unlikely to manifest accidentally, but I
think you could trigger it by setting the data-based rekey threshold
very low.

8 years agoMay as well set FD_CLOEXEC on the signal pipe as well.
Ben Harris [Sun, 1 May 2016 15:55:07 +0000 (17:55 +0200)]
May as well set FD_CLOEXEC on the signal pipe as well.

8 years agoUnix Plink: Set O_NONBLOCK on the SIGWINCH pipe.
Ben Harris [Sun, 1 May 2016 15:46:40 +0000 (17:46 +0200)]
Unix Plink: Set O_NONBLOCK on the SIGWINCH pipe.

This should avoid the possibility of the SIGWINCH handler's blocking
when trying to write to the pipe.  This could only happen if we'd
somehow received PIPE_BUF SIGWINCHes without reading the pipe, which
would be difficult to achieve.

While we're at it, also set O_NONBLOCK on the reading side of the pipe,
just in case.

8 years agouxcons: Don't try to include <sys/select.h> on systems that don't have it.
Ben Harris [Sun, 1 May 2016 16:11:50 +0000 (18:11 +0200)]
uxcons: Don't try to include <sys/select.h> on systems that don't have it.

Also include <sys/time.h> for ancient systems that define select()
there.

8 years agouxcons: Fix on musl libc
Kylie McClain [Fri, 29 Apr 2016 02:40:32 +0000 (22:40 -0400)]
uxcons: Fix on musl libc

musl libc exports FD_SET and friends in sys/select.h.

8 years agoShared ssh_send_channel_data for both SSH-1 and SSH-2.
Ben Harris [Sat, 23 Apr 2016 14:51:45 +0000 (15:51 +0100)]
Shared ssh_send_channel_data for both SSH-1 and SSH-2.

Saves duplication between agent and port forwarding code.

Conflicts:
ssh.c

8 years agoCall ssh2_try_send() from ssh2_add_channel_data() and rename latter
Ben Harris [Sat, 23 Apr 2016 12:17:33 +0000 (13:17 +0100)]
Call ssh2_try_send() from ssh2_add_channel_data() and rename latter

All calls to ssh2_add_channel_data() were followed by a call to
ssh2_try_send(), so it seems sensible to replace ssh2_add_channel_data()
with ssh2_send_channel_data(), which does both.

8 years agoSimplifiy handling of stdin data in SSH-2.
Ben Harris [Sat, 23 Apr 2016 12:10:11 +0000 (13:10 +0100)]
Simplifiy handling of stdin data in SSH-2.

Specifically, don't try to unblock all channels just because we've got
something to send on the main one.  It looks like the code to do that
was left over from when SSH_MSG_CHANNEL_ADJUST was handled in
do_ssh2_authconn().

8 years agoPut handling of incoming data on agent channels into its own function.
Ben Harris [Fri, 22 Apr 2016 22:00:46 +0000 (23:00 +0100)]
Put handling of incoming data on agent channels into its own function.

This function can be shared between SSH-1 and SSH-2, and makes the
per-protocol data-handling functions more generic.

8 years agoSet cfg.ssh_simple in Windows Plink when there are no forwardings.
Ben Harris [Fri, 15 Apr 2016 21:58:26 +0000 (22:58 +0100)]
Set cfg.ssh_simple in Windows Plink when there are no forwardings.

Unix Plink had had this for ages, but for some reason I didn't add it to
Windows Plink at the same time.

8 years agoPut DH group1-sha1 KEX below 'warn' by default.
Jacob Nevins [Sun, 27 Mar 2016 16:24:44 +0000 (17:24 +0100)]
Put DH group1-sha1 KEX below 'warn' by default.

Also try to upgrade the settings of people who haven't changed the
defaults; but anyone who has, or anyone who's used the pre-release
snapshots with elliptic-curve support, will have to review their
settings manually.

8 years agoFix plurality in unknown host keys log message.
Jacob Nevins [Sun, 10 Apr 2016 14:57:00 +0000 (15:57 +0100)]
Fix plurality in unknown host keys log message.

8 years agoCorrect description of NO_SECURITY.
Jacob Nevins [Sun, 10 Apr 2016 13:37:43 +0000 (14:37 +0100)]
Correct description of NO_SECURITY.

8 years agoEnable various features in MinGW builds.
Jacob Nevins [Sun, 10 Apr 2016 13:40:39 +0000 (14:40 +0100)]
Enable various features in MinGW builds.

I've reset the baseline to be the version of mingw-w64 that comes with
Ubuntu 14.04. Right now, that means no features need to be omitted; all
you need to do is set TOOLPATH to i686-w64-mingw32- .

I've removed -mno-cygwin without comment. Toolchains which don't support
this flag have been around since at least 2012, so we can probably
assume that no-one cares about older toolchains by now.

8 years agoRename Makefile.cyg to Makefile.mgw.
Jacob Nevins [Sun, 10 Apr 2016 13:26:54 +0000 (14:26 +0100)]
Rename Makefile.cyg to Makefile.mgw.

It's really only useful with MinGW rather than a Cygwin toolchain these
days, as recent versions of the latter insist against linking with the
Cygwin DLL.

(I think it may no longer be possible to build with Cygwin out of the
box at all these days, but I'm not going to say so without having
actually checked that's the case. Settle for listing MinGW first in
various comments and docs.)

8 years agowinsftp.c needs winsecur.h for process protection.
Jacob Nevins [Sun, 10 Apr 2016 14:08:57 +0000 (15:08 +0100)]
winsftp.c needs winsecur.h for process protection.

8 years agoFix format strings for Windows serial parameters.
Jacob Nevins [Sun, 10 Apr 2016 13:25:34 +0000 (14:25 +0100)]
Fix format strings for Windows serial parameters.

8 years agoSpecify integer type for access rights.
Jacob Nevins [Sun, 10 Apr 2016 13:24:39 +0000 (14:24 +0100)]
Specify integer type for access rights.

Fixes a warning from MinGW GCC.

8 years agoFixed unused-variable warnings from MinGW gcc.
Jacob Nevins [Sun, 10 Apr 2016 13:24:04 +0000 (14:24 +0100)]
Fixed unused-variable warnings from MinGW gcc.

8 years agoSwitch to flow-control-based SFTP uploading.
Ben Harris [Fri, 8 Apr 2016 23:24:12 +0000 (00:24 +0100)]
Switch to flow-control-based SFTP uploading.

Formerly PuTTY's SFTP code would transmit (or buffer) a megabyte of data
before even starting to look for acknowledgements, but wouldn't allow
there to be more than a megabyte of unacknowledged data at a time.  Now,
instead, it pays attention to whether the transmit path is blocked, and
transmits iff it isn't.

This should mean that SFTP goes faster over long fat pipes, and also
doesn't end up buffering so much over thin ones.

I practice, I tend to run into other performance limitations (such as
TCP or SSH-2 windows) before this enhancement looks particularly good,
but with an artificial lag of 250 ms on the loopback interface this
patch almost doubles my upload speed, so I think it's worthwhile.

8 years agopscp: pull out upload block size into a constant.
Ben Harris [Fri, 8 Apr 2016 23:01:13 +0000 (00:01 +0100)]
pscp: pull out upload block size into a constant.

8 years agoCorrect a comment: OUR_V2_WINSIZE is now the default, not maximum.
Ben Harris [Fri, 8 Apr 2016 23:46:25 +0000 (00:46 +0100)]
Correct a comment: OUR_V2_WINSIZE is now the default, not maximum.

8 years agoUpdate build script for Inno Setup 5.5.9.
Simon Tatham [Fri, 8 Apr 2016 10:00:08 +0000 (11:00 +0100)]
Update build script for Inno Setup 5.5.9.

I've just upgraded my build environment to the latest Inno Setup
(apparently fixing some DLL hijacking issues), and found that the
build script doesn't run any more because the name of the output file
has changed - it used to produce Output/setup.exe, but now it produces
Output/mysetup.exe.

Rather than just fixing the build script to expect the new name, I've
explicitly specified an output filename of my own choice in putty.iss,
so that the build script should now work with versions before and
after the change.

8 years agoAdd some missing 'const' in version.c's string data.
Simon Tatham [Thu, 7 Apr 2016 06:52:55 +0000 (07:52 +0100)]
Add some missing 'const' in version.c's string data.

I can't believe this codebase is around 20 years old and has had
multiple giant const-fixing patches, and yet there are _still_ things
that should have been const for years and aren't.

8 years agoFix semantics of empty string in mkfiles.pl "!cflags".
Simon Tatham [Thu, 7 Apr 2016 06:52:01 +0000 (07:52 +0100)]
Fix semantics of empty string in mkfiles.pl "!cflags".

Previously, if you tried to set the special cflags for an object file
to the empty string, mkfiles.pl would normalise that to the string
"1". I'm not entirely sure why - that line of code was added without
explanation in commit 64150a5ef which brought in that directive in the
first place - but I have to guess that it was left over from some
earlier design iteration in which I hadn't quite decided whether I was
going to need a string or a boolean to separate version.o from other
objects.

Of course, setting an object's cflags to "" is a bit of a weird thing
to want to do anyway - why not just leave them unset? But in fact I've
now thought of something useful for it to do: this commit arranges
that setting cflags="" has the effect (in the 'am' makefile type) of
separating the object out into its own little automake library but not
actually giving that library any separate cflags. And the point of
_that_, in turn, will be that then you can add cflags to it
_conditionally_ in a "!begin am" snippet, e.g. conditionalised on
something in configure.

8 years agoWindows PuTTYgen: stop saying "Pageant" in the About box!
Simon Tatham [Wed, 6 Apr 2016 13:12:45 +0000 (14:12 +0100)]
Windows PuTTYgen: stop saying "Pageant" in the About box!

Ahem. Cut-and-paste goof that I introduced in commit 2eb952ca3, when I
moved the application names out of separate text controls in the
resource-file dialog descriptions.

8 years agoFix duplicate definition of typedef 'bufchain'.
Simon Tatham [Wed, 6 Apr 2016 08:06:19 +0000 (09:06 +0100)]
Fix duplicate definition of typedef 'bufchain'.

This was defined in misc.h, and also in network.h (because one
function prototype needed to refer to it in the latter), leading to a
build failure if any source file inconveniently included both those
headers.

Fixed by guarding each copy of the typedef with a #ifdef.

8 years agoGTK 3: tweak margin below the gtkask drawing areas.
Simon Tatham [Mon, 4 Apr 2016 10:49:05 +0000 (11:49 +0100)]
GTK 3: tweak margin below the gtkask drawing areas.

A side effect of commit 1f9df706b seems to have been to squash those
areas right up against the bottom of the dialog box, which is ugly. I
don't fully understand why it only happens to those drawing areas and
not to buttons placed in the fake 'action area' by other dialogs, but
anyway, adding an explicit margin-bottom attribute seems to solve it.

8 years agoAccount for GtkApplicationWindow menu bar in geometry hints.
Simon Tatham [Mon, 4 Apr 2016 10:28:34 +0000 (11:28 +0100)]
Account for GtkApplicationWindow menu bar in geometry hints.

This is another widget that can appear in the top-level window, in
addition to the drawing area and scrollbar we put there ourselves, and
hence which needs to be accounted for when figuring out the
relationship between the drawing area size in character cells and the
full window size in pixels.

Finding the menu bar widget itself is a bit of a hassle, but having
found it, dealing with it is basically the same as dealing with the
scrollbar, only with x and y swapped.

8 years agoGTK: stop using gtk_window_parse_geometry.
Simon Tatham [Mon, 4 Apr 2016 10:27:01 +0000 (11:27 +0100)]
GTK: stop using gtk_window_parse_geometry.

This function, which parses the X11-style '-geometry WxH+X+Y' option
argument and automatically loads the result into the window, is also
being deprecated.

Fortunately we already had a fallback option for GTK1 (which didn't
have gtk_window_parse_geometry in the first place), calling the Xlib
geometry-parsing function and manually loading the results into GTK.
The method of loading into GTK is not the same between the two
versions, but the basic strategy is still viable.

For the sake of maintaining and testing fewer ifdef branches, I've
removed the use of gtk_window_parse_geometry _completely_, even in
GTK2 which did have it. GTK2 now uses the same strategy that I've
switched to for GTK3.

8 years agoGTK: stop using geometry-based window sizing functions.
Simon Tatham [Mon, 4 Apr 2016 10:24:24 +0000 (11:24 +0100)]
GTK: stop using geometry-based window sizing functions.

gtk_window_resize_to_geometry and gtk_window_set_default_geometry are
deprecated as of GTK 3.20, so now we do the geometry -> pixel size
conversion on our side.

8 years agoGTK: split out the computation part from set_geom_hints.
Simon Tatham [Mon, 4 Apr 2016 10:23:25 +0000 (11:23 +0100)]
GTK: split out the computation part from set_geom_hints.

This is preparation for dealing with the fact that GTK's geometry-
based API routines for setting the window size are being deprecated:
we'll no longer be able to specify a width/height in characters and
have GTK convert that into a pixel size based on the geometry hints
we'd already fed it. So we'll need to do that conversion ourselves,
and the easiest approach is to make it easy to recompute the geometry
hints on our side whenever we need them.

8 years agoGTK 3.20 compatibility: switch to gdk_seat_grab.
Simon Tatham [Mon, 4 Apr 2016 10:21:54 +0000 (11:21 +0100)]
GTK 3.20 compatibility: switch to gdk_seat_grab.

gdk_device_grab and all its preparatory faff are now deprecated, and
gdk_seat_grab is the new thing. Introduce yet another branch to all
the ifdefs for keyboard-grabbing. On the plus side, at least it's
slightly simpler than the GdkDevice business.

8 years agoReorganise the Bugs and More Bugs config panels.
Simon Tatham [Sun, 3 Apr 2016 17:16:44 +0000 (18:16 +0100)]
Reorganise the Bugs and More Bugs config panels.

Now bugs that are still likely to come up with relatively recent
server software (because they're only a few years fixed, or because
they're the sort of mistake that new server implementors will likely
make again) are in the Bugs panel, and very old things long since
fixed are relegated to More Bugs.

In particular, More Bugs contains everything SSH-1 related.

8 years agoMerge branch 'master' of ssh://tartarus.org/putty
Owen Dunn [Sun, 3 Apr 2016 14:09:59 +0000 (15:09 +0100)]
Merge branch 'master' of ssh://tartarus.org/putty