]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
7 years agoUpdate version number for 0.68 release. 0.68
Simon Tatham [Fri, 17 Feb 2017 19:39:58 +0000 (19:39 +0000)]
Update version number for 0.68 release.

This commit also updates the dumps of Plink's and PSCP's help output,
adding the -proxycmd option to both and the -shareexists option to
Plink.

(Or rather, _re_-adding the latter, since it was introduced in error
by commit 07af4ed10 due to a branch management error and hastily
removed again in 29e8c24f9. This time it really does match reality.)

7 years agoRelease checklist updates.
Simon Tatham [Sat, 18 Feb 2017 17:06:46 +0000 (17:06 +0000)]
Release checklist updates.

These reflect the fact that I'm increasingly preferring to make a
release-candidate build a few days in advance of the actual release,
and give the team time to do a bit of testing on it before putting it
up on the live website. Hence, I can't _quite_ fill in everything in
the website announcement ahead of time - the release date has to wait
until we know what it is, which means I need to have 'now fill in the
release date' as part of the go-live checklist.

Also, I've provided a better bob command for doing a release build
(putting it somewhere safe to begin with, rather than leaving it
precariously in my normal build directory). And while I'm here, I've
standardised all my placeholder version numbers to X.YZ; previously
half of them said 0.XX :-)

7 years agoFix the '--without-gtk' mode in configure.
Simon Tatham [Sat, 18 Feb 2017 16:50:48 +0000 (16:50 +0000)]
Fix the '--without-gtk' mode in configure.

I had accidentally included the experimental "XT" app class (the
GtkApplication-based packaging of Unix PuTTY/pterm for OS X) among the
things that should still be built even when GTK is absent. That's
definitely wrong.

7 years agoClear out more XXX-REVIEW-BEFORE-RELEASE.
Jacob Nevins [Fri, 17 Feb 2017 00:18:37 +0000 (00:18 +0000)]
Clear out more XXX-REVIEW-BEFORE-RELEASE.

7 years agoUpdate documentation for 0.68.
Simon Tatham [Sat, 11 Feb 2017 07:08:53 +0000 (07:08 +0000)]
Update documentation for 0.68.

Several places in the docs were labelled for review because they need
to change when 0.68's feature set comes in - no SSH-2 to SSH-1
fallback any more, but on the other hand, Unix Pageant now exists.

7 years agoFix a broken gitweb link.
Jacob Nevins [Sat, 18 Feb 2017 09:19:24 +0000 (09:19 +0000)]
Fix a broken gitweb link.

7 years agoImplement deferred closing of Windows handle-sockets.
Simon Tatham [Thu, 16 Feb 2017 20:26:58 +0000 (20:26 +0000)]
Implement deferred closing of Windows handle-sockets.

When a handle socket is in THAWING state and handle_socket_unfreeze is
gradually passing the backlogged data on to the plug, the plug might
suddenly turn round and close the socket in the course of handling
plug_receive(), which means that handle_socket_unfreeze had better be
careful not to have had everything vanish out from under it when that
call returns. To solve this, I've added a 'deferred close' flag which
handle_socket_unfreeze can set around its call to plug_receive, and
handle_socket_close will detect that and not actually free the socket,
instead leaving that for handle_socket_unfreeze to do under its own
control.

7 years agoNote the interaction of jump lists and -cleanup.
Jacob Nevins [Fri, 17 Feb 2017 00:03:11 +0000 (00:03 +0000)]
Note the interaction of jump lists and -cleanup.

Also note that recent installers don't prompt to -cleanup (this started
with 0.67's MSI installer).

7 years agoDocument VS2015 impact on very old Windows.
Jacob Nevins [Thu, 16 Feb 2017 23:47:03 +0000 (23:47 +0000)]
Document VS2015 impact on very old Windows.

(In a XXX-REVIEW-BEFORE-RELEASE form.)

Also, note the effect of compilation with different Visual Studio
versions on Windows version compatibility in the source README, for the
sake of having it written down somewhere.

7 years agoMSI installer: add version info to product name.
Jacob Nevins [Thu, 16 Feb 2017 10:08:14 +0000 (10:08 +0000)]
MSI installer: add version info to product name.

This appears to be conventional, and the full version info for builds
like development snapshots is not visible elsewhere in Control Panel.

7 years agoRemove references to "Win32" and "32-bit Windows".
Jacob Nevins [Wed, 15 Feb 2017 23:58:25 +0000 (23:58 +0000)]
Remove references to "Win32" and "32-bit Windows".

They were there mainly to distinguish from 16-bit Windows, which hasn't
been a thing since before a noticeable fraction of the userbase were
born, probably. These days the obvious comparison is with 64-bit
Windows.

Also tweak some wording to reflect that official PuTTY executables are
not necessarily 32-bit any more, and add some XXX-REVIEW-BEFORE-RELEASE
in the same vein.

7 years agosink(): finish waiting for remote EOF after a local error.
Simon Tatham [Wed, 15 Feb 2017 21:41:28 +0000 (21:41 +0000)]
sink(): finish waiting for remote EOF after a local error.

We responded to a local error writing out the destination file by
going into a mode where we just looped round receiving and throwing
away data until our count of the file size reached the file size we
expected - but once we were in that mode, we never actually
incremented the count!

7 years agoscp_recv_filedata: handle EOF more sensibly.
Simon Tatham [Wed, 15 Feb 2017 21:39:23 +0000 (21:39 +0000)]
scp_recv_filedata: handle EOF more sensibly.

xfer_download_data could return actuallen as either 0 or -1 to
indicate EOF. Now it's always 0, and scp_recv_filedata actually checks
for that case and reports an error.

7 years agoReturn an error if there's an error doing pscp -ls
Owen Dunn [Wed, 15 Feb 2017 20:31:56 +0000 (20:31 +0000)]
Return an error if there's an error doing pscp -ls

7 years agoReturn zero when reporting our version.
Owen Dunn [Wed, 15 Feb 2017 19:50:14 +0000 (19:50 +0000)]
Return zero when reporting our version.

When called with -V to ask for our version, return 0 rather than 1.
This is the usual behaviour observed by ssh(1) and other Unix commands.
Also use exit() rather than cleanup_exit() in pscp.c and psftp.c ; at
this point we have nothing to cleanup!

7 years agoInclude the compile-time GTK version in the build info.
Simon Tatham [Wed, 15 Feb 2017 19:29:05 +0000 (19:29 +0000)]
Include the compile-time GTK version in the build info.

It's obvious to the trained eye whether GTK PuTTY was compiled against
GTK2 or GTK3, but the untrained eye would probably appreciate a little
help, and even the trained eye probably can't tell GTK 3.18 from 3.19
at a glance :-)

7 years agoFix multiple bugs in freeze/thaw of Windows handle-sockets.
Simon Tatham [Wed, 15 Feb 2017 19:19:38 +0000 (19:19 +0000)]
Fix multiple bugs in freeze/thaw of Windows handle-sockets.

Firstly, I had asserted that data would never arrive on a handle
socket in state FREEZING, which is just an error, because FREEZING is
precisely the state of not being quite frozen _yet_ because one last
read is still expected to arrive from the winhandl.c reading subthread
which it's too late to cancel. I meant to assert that it wasn't
FROZEN.

Secondly, when the handle socket was in state FREEZING, I failed to
actually _set_ it to FROZEN.

And thirdly, when the handle socket starts thawing again (i.e. there's
now outgoing buffer space so we can start sending our backlogged
data), I forgot to ever call bufchain_consume, so that the same block
of data would get sent repeatedly.

I can only assume that nothing I've ever done has actually exercised
this code!

7 years agoWindows Plink: treat EOF at host key prompt as 'abort connection'.
Simon Tatham [Wed, 15 Feb 2017 06:03:50 +0000 (06:03 +0000)]
Windows Plink: treat EOF at host key prompt as 'abort connection'.

Thanks to Didrik Nordström for pointing out that we currently treated
it as 'whatever happened to be in line[0] before ReadFile didn't get
any data'.

7 years agouxpgnt: correct control flow in find_key().
Simon Tatham [Wed, 15 Feb 2017 05:31:30 +0000 (05:31 +0000)]
uxpgnt: correct control flow in find_key().

If we try to interpret a string argument as the name of a key file,
sometimes we it's in circumstances where we _know_ it's a key file, so
we must print an error message and return failure if the file can't be
loaded. Other times it's not, and we just fall back to interpreting
the argument in some other way (e.g. as a pattern match against the
comment or fingerprint of a key already in the agent).

My code dealing with failure returns from the public-key loading
functions were mishandling the latter case, if they identified a file
as existing and looking more or less like some kind of key file but
then it turned out to have a format error; they would try to copy and
return a public key that they didn't actually have. Even if
pageant_pubkey_copy avoided crashing as a result, this would still
inhibit the fallback to treating the input string as some other kind
of pattern match.

7 years agoRemove a redundant ?: in the nethack_keypad code.
Simon Tatham [Wed, 15 Feb 2017 05:21:13 +0000 (05:21 +0000)]
Remove a redundant ?: in the nethack_keypad code.

I think all of the cases in this switch must have originally said
(shift_state ? 'this' : 'that'), and in all but the VK_NUMPAD5 case
the two options were different, and I left VK_NUMPAD5 containing a
redundant ?: just to make it line up in a nice table with the others.
But now the others all have more options than that because I had to
support Ctrl as well as Shift modifiers, so there's no reason to have
that silly ?: lingering around (and it annoys Coverity).

7 years agoA few more missing frees.
Simon Tatham [Wed, 15 Feb 2017 05:31:51 +0000 (05:31 +0000)]
A few more missing frees.

Naturally I didn't quite manage to catch _everything_ Coverity
reported to me in my first pass through the results.

7 years agoFixes for winelib building (used by our Coverity build).
Simon Tatham [Tue, 14 Feb 2017 23:19:13 +0000 (23:19 +0000)]
Fixes for winelib building (used by our Coverity build).

Avoided referring to some functions and header files that aren't there
in the winelib world (_vsnprintf, _stricmp, SecureZeroMemory,
multimon.h), and worked around a really amazingly annoying issue in
which Winelib objects to you using the type 'fd_set' unless you
included winsock2.h before stdlib.h.

7 years agoProperly check the lengths of Unix-socket pathnames.
Simon Tatham [Tue, 14 Feb 2017 21:59:52 +0000 (21:59 +0000)]
Properly check the lengths of Unix-socket pathnames.

If something is too long to fit in a sun_addr, we should spot that
well in advance and not try.

7 years agoTighten up bounds-checking of agent responses.
Simon Tatham [Tue, 14 Feb 2017 21:52:28 +0000 (21:52 +0000)]
Tighten up bounds-checking of agent responses.

I think an agent sending a string length exceeding the buffer bounds
by less than 4 could have made PuTTY read beyond its own buffer end.
Not that I really think a hostile SSH agent is likely to be attacking
PuTTY, but it's as well to fix these things anyway!

7 years agoFix completely broken dialog-building functions.
Simon Tatham [Tue, 14 Feb 2017 21:15:02 +0000 (21:15 +0000)]
Fix completely broken dialog-building functions.

The loops that were supposed to count up the number of buttons in the
variadic argument list forgot to increment the counter.

On the other hand, these functions aren't actually _used_ anywhere in
the current code - looks as if commit 616c837cf was the last time they
were seen - but manual dialog stuff like PuTTYgen might yet find a use
for them in future.

7 years agoPut in some explicit null-pointer checks.
Simon Tatham [Tue, 14 Feb 2017 20:47:16 +0000 (20:47 +0000)]
Put in some explicit null-pointer checks.

I think these were not strictly necessary, since passing a null
pointer to access(2) would have resulted in EINVAL rather than a
segfault. But it's clearer to put them in (and keeps static checkers a
bit happier).

7 years agoFix a typoed end-of-string check in testbn.
Simon Tatham [Tue, 14 Feb 2017 20:39:22 +0000 (20:39 +0000)]
Fix a typoed end-of-string check in testbn.

I was testing the actual pointer against NULL instead of testing the
pointed-to character against NUL.

7 years agowintime: add a precautionary memset to zero.
Simon Tatham [Tue, 14 Feb 2017 20:29:38 +0000 (20:29 +0000)]
wintime: add a precautionary memset to zero.

Coverity observes that sometimes 'struct tm' can have other fields
(e.g. glibc's tm_gmtoff), so it's as well to make sure we initialise
the whole thing to zero.

7 years agouxpgnt: fix an uninitialised structure field in find_key().
Simon Tatham [Tue, 14 Feb 2017 20:26:03 +0000 (20:26 +0000)]
uxpgnt: fix an uninitialised structure field in find_key().

Thanks, Coverity - I must have been lucky that Unix Pageant in client
mode hasn't so far happened to have this field come out non-NULL, or
else pageant_pubkey_copy would have tried to dupstr a garbage pointer.

7 years agolz77_compress: change scope of variable 'hash'.
Simon Tatham [Tue, 14 Feb 2017 22:13:24 +0000 (22:13 +0000)]
lz77_compress: change scope of variable 'hash'.

This makes it clearer that it doesn't persist beyond this block, and
would have made it much more obvious that the assignment to it removed
in the previous commit was pointless.

7 years agoRemove assorted dead code.
Simon Tatham [Tue, 14 Feb 2017 20:22:05 +0000 (20:22 +0000)]
Remove assorted dead code.

Assignments that are overwritten shortly afterwards and never used,
and a completely unused variable. Also, the bogus array access in
testbn.c could have actually accessed one beyond the array limit
(though of course it's only in a test harness).

7 years agoFix freeing of retkey in openssh_new_read.
Simon Tatham [Tue, 14 Feb 2017 21:31:12 +0000 (21:31 +0000)]
Fix freeing of retkey in openssh_new_read.

Now it's always freed in the cleanup epilogue (unless we're returning
it), rather than ad-hoc earlier in the code. That should make it more
reliably freed on error paths.

7 years agoAdd an assortment of missing frees and closes.
Simon Tatham [Tue, 14 Feb 2017 20:42:26 +0000 (20:42 +0000)]
Add an assortment of missing frees and closes.

Coverity's resource-leak checker is on the ball as usual.

7 years agoDocument proxy logging control.
Jacob Nevins [Sat, 11 Feb 2017 23:30:52 +0000 (23:30 +0000)]
Document proxy logging control.

(This was added in 7c65b9c57.)

7 years agoDocument -proxycmd in help and man pages.
Jacob Nevins [Sat, 11 Feb 2017 23:03:46 +0000 (23:03 +0000)]
Document -proxycmd in help and man pages.

Also, in the main documentation, note the hazard that backslashes in the
command argument must be doubled.

7 years agoAdd -c/-s to Unix 'pageant --help'.
Jacob Nevins [Sat, 11 Feb 2017 22:12:33 +0000 (22:12 +0000)]
Add -c/-s to Unix 'pageant --help'.

7 years agoAdd 'plink -shareexists' to man page.
Jacob Nevins [Sat, 11 Feb 2017 22:08:06 +0000 (22:08 +0000)]
Add 'plink -shareexists' to man page.

7 years agoFix missing options in man pages.
Jacob Nevins [Sat, 11 Feb 2017 22:04:41 +0000 (22:04 +0000)]
Fix missing options in man pages.

None of them documented -4, -6, -noagent, or -agent.
Ask document 'plink -nc host:port'.

7 years agoDocument cmdgen ability to read public-only keys.
Jacob Nevins [Sat, 11 Feb 2017 21:12:16 +0000 (21:12 +0000)]
Document cmdgen ability to read public-only keys.

(This was added in 3935cc3af.)

7 years agoUpdate man page for puttygen --random-device.
Jacob Nevins [Sat, 11 Feb 2017 20:32:54 +0000 (20:32 +0000)]
Update man page for puttygen --random-device.

7 years agoUnix 'puttygen --help' was a mess.
Jacob Nevins [Sat, 11 Feb 2017 20:12:55 +0000 (20:12 +0000)]
Unix 'puttygen --help' was a mess.

Bring it into line with the other PuTTY tools: --help goes to stdout,
has a one-line purpose and brief version information, --version ends
with a newline.

(Also, tweak text bring the help message under 80 columns.)

7 years agoLog when -restrict-acl is in use.
Jacob Nevins [Sat, 11 Feb 2017 00:44:00 +0000 (00:44 +0000)]
Log when -restrict-acl is in use.

Partly to reassure the user that they got what they asked for, and
partly so that's a clue for us in the logs when we get bug reports.

This involved repurposing platform_psftp_post_option_setup() (no longer
used since e22120fe) as platform_psftp_pre_conn_setup(), and moving it
to after logging is set up.

7 years agoStart logging earlier in PSCP and PSFTP.
Jacob Nevins [Sat, 11 Feb 2017 00:23:36 +0000 (00:23 +0000)]
Start logging earlier in PSCP and PSFTP.

We were missing log messages about the start of the network connection.

7 years agoRemove -cleanup-during-uninstall option.
Jacob Nevins [Fri, 10 Feb 2017 00:22:18 +0000 (00:22 +0000)]
Remove -cleanup-during-uninstall option.

It was never a documented option, and hasn't been used for anything
since d0399966.

7 years agoOne more warning fix: spurious 'const' on functions.
Simon Tatham [Sun, 5 Feb 2017 12:08:13 +0000 (12:08 +0000)]
One more warning fix: spurious 'const' on functions.

These must have been absent-mindedly copied from function declarations
of the form 'const type *fn(args)', where the 'const' is meaningful
and describes the data pointed to by the returned pointer, to
functions of the form 'const type fn(args)' where the 'const' is
completely pointless.

7 years agoFix a few more clang-generated warnings.
Simon Tatham [Sun, 5 Feb 2017 11:19:12 +0000 (11:19 +0000)]
Fix a few more clang-generated warnings.

These are benign, I think. clang warns about casting non-pointer-sized
integers to pointers, but the Windows API actually does sometimes
involve values that are either pointers or _small_ integers, so in the
two cases involved I just cast through ULONG_PTR to silence the
warning. And clang insists that the integer whose address I give to
sk_getxdmdata is still uninitialised afterwards, which is just a lie.

7 years agoStop using MS-deprecated names stricmp and strnicmp.
Simon Tatham [Sun, 5 Feb 2017 11:13:45 +0000 (11:13 +0000)]
Stop using MS-deprecated names stricmp and strnicmp.

clang-cl generates warnings saying they're deprecated, in favour of
the same names but prefixed with an underscore. The warnings are
coming from the standard MS headers, and I'm already #defining those
names differently on Unix, so I'll honour them.

7 years agoclang-specific pragmas to suppress -Wmissing-braces.
Simon Tatham [Sun, 5 Feb 2017 11:19:22 +0000 (11:19 +0000)]
clang-specific pragmas to suppress -Wmissing-braces.

When I added some extra braces in commit 095072fa4 to suppress this
warning, I think in fact I did the wrong thing, because the
declaration syntax I was originally using is the Microsoft-recommended
one in spite of clang not liking it - I think MS would be within their
rights (should they feel like it) to add those missing braces in a
later version of the WinSock headers, which would make the current
warning-clean code stop compiling. So it's better to put the code back
as it was, and avoid the clang warning by using clang's
warning-suppression pragmas for just those declarations.

I've also done the same thing in winnet.c, for two initialisers of
IPv6 well-known addresses which had the same problem (but which I
didn't notice yesterday because a misjudged set of Windows version
macros had prevented me from compiling that file successfully at all).

7 years agoNew makefile, for Windows cross-builds with clang-cl.
Simon Tatham [Sun, 5 Feb 2017 10:59:08 +0000 (10:59 +0000)]
New makefile, for Windows cross-builds with clang-cl.

This was very strange to write, because it's a bizarre combination of
the GNU-make-isms and rc commands of Makefile.mgw with the cl and link
commands of Makefile.vc (but also the latter thankfully doesn't need
those horrible response files).

I've added a big comment in mkfiles.pl about what the build
requirements for this makefile actually are, which _hopefully_ will be
usable by people other than me.

7 years agoLog proxy host correctly in Event Log.
Jason Andryuk [Sat, 4 Feb 2017 14:36:12 +0000 (14:36 +0000)]
Log proxy host correctly in Event Log.

We were showing the destination hostname -- oops.

7 years agoDocument Inno Setup's new lack of cleanup.
Jacob Nevins [Sat, 4 Feb 2017 12:48:50 +0000 (12:48 +0000)]
Document Inno Setup's new lack of cleanup.

We used to offer to clean up saved sessions, so we should mention that
we don't for the benefit of users of old versions, who might have been
relying on it.

7 years agoNote legacy status of putty.iss.
Jacob Nevins [Sat, 4 Feb 2017 12:48:31 +0000 (12:48 +0000)]
Note legacy status of putty.iss.

Also correct last tested version.

7 years agoDocument '-restrict-acl' vs subprocesses.
Jacob Nevins [Sat, 4 Feb 2017 12:12:18 +0000 (12:12 +0000)]
Document '-restrict-acl' vs subprocesses.

(Since we've thought about it.)

7 years agoReference '-proxycmd' from main local proxy docs.
Jacob Nevins [Sat, 4 Feb 2017 12:05:14 +0000 (12:05 +0000)]
Reference '-proxycmd' from main local proxy docs.

7 years agoPass -restrict-acl, if given, through to sub-PuTTYs.
Simon Tatham [Sat, 4 Feb 2017 07:57:36 +0000 (07:57 +0000)]
Pass -restrict-acl, if given, through to sub-PuTTYs.

This change applies to every situation when GUI PuTTY knowingly spawns
another GUI PuTTY, to wit, the System menu options 'New Session',
'Duplicate Session' and the 'Saved Sessions' submenu.

(Literally speaking, what we actually pass through to the sub-PuTTY's
command line is not the "-restrict-acl" option itself, but a special
prefix "&R", which has the same meaning but which lives in the special
pre-argv-splitting command-line namespace like the magic options used
for Duplicate Session and the old '@sessionname' prefix which the
Saved Sessions submenu still uses. Otherwise, by the time we split up
argv and recognised -restrict-acl, it would be too late to parse those
other options.)

One case in which PuTTY spawns a subprocess and this change _doesn't_
apply is when the subprocess is a proxy command which happens to be a
Plink. Recognising Plink commands in that situation would be fragile
and unreliable, and in any case if the user wants a proxy Plink to be
ACL-restricted, they are in control of its exact command line so they
can add -restrict-acl themselves.

7 years agoA bunch of further warning fixes in the Windows code.
Simon Tatham [Fri, 3 Feb 2017 19:37:59 +0000 (19:37 +0000)]
A bunch of further warning fixes in the Windows code.

These ones are stylistic rather than potential bugs: mostly signedness
of char pointers in cases where they clearly aren't going to cause the
wrong thing to actually happen, and one thing in winsecur.c where
clang would have preferred an extra pair of braces around some
initialisers but it's legal with or without. But since some of clang's
warnings turn out to be quite useful, it seems worth silencing these
harmless ones so as to be able to see the rest.

7 years agoMissing initialisation in winsecur.c.
Simon Tatham [Fri, 3 Feb 2017 19:36:46 +0000 (19:36 +0000)]
Missing initialisation in winsecur.c.

We might have returned true from getsids() by mistake, even if
something had gone wrong. Thanks again, clang.

7 years agoMove declaration of frontend_is_utf8 into putty.h.
Simon Tatham [Fri, 3 Feb 2017 19:35:41 +0000 (19:35 +0000)]
Move declaration of frontend_is_utf8 into putty.h.

It's a function that exists on all platforms, not just on Unix - it's
used in ldisc.c - so it shouldn't have been declared only in unix.h.
Score another for clang's warnings.

7 years agoFix an EOF-testing goof in winhandl.c.
Simon Tatham [Fri, 3 Feb 2017 19:33:50 +0000 (19:33 +0000)]
Fix an EOF-testing goof in winhandl.c.

I was having a play with clang's MSVC compatibility mode, just to see
how much of PuTTY it could compile, and one of its warnings pointed
out this error which must have crept in when I was changing the EOF
flags in winhandl.c from booleans to three-state enums - I left the !
on the front of what was previously an if (!thing) and needed to turn
into if (thing == EOF_NO).

7 years agoFix error reporting pointer parameters in winsecur.c.
Simon Tatham [Wed, 1 Feb 2017 20:42:21 +0000 (20:42 +0000)]
Fix error reporting pointer parameters in winsecur.c.

Several functions were passing a 'char *error' and assigning error
messages directly into 'error', where they should have been passing
'char **error' and assigning error messages into '*error' if the error
message is to be returned to the caller. This would have led to
incomplete error messages.

7 years agoRemove duplicate definition of AGENT_MAX_MSGLEN.
Simon Tatham [Mon, 30 Jan 2017 19:42:28 +0000 (19:42 +0000)]
Remove duplicate definition of AGENT_MAX_MSGLEN.

Now all references of that constant use the same definition in
pageant.h, so it'll be easy to change if we ever need to.

7 years agoRefuse to forward agent messages > AGENT_MAX_MSGLEN.
Simon Tatham [Mon, 30 Jan 2017 19:42:25 +0000 (19:42 +0000)]
Refuse to forward agent messages > AGENT_MAX_MSGLEN.

Mostly so that we don't have to malloc contiguous space for them
inside PuTTY; since we've already got a handy constant saying how big
is too big, we might as well use it to sanity-check the contents of
our agent forwarding channels.

7 years agoTurn off Windows process ACL restriction by default.
Simon Tatham [Sat, 28 Jan 2017 21:56:28 +0000 (21:56 +0000)]
Turn off Windows process ACL restriction by default.

As documented in bug 'win-process-acl-finesse', we've had enough
assorted complaints about it breaking various non-malicious pieces of
Windows process interaction (ranging from git->plink integration to
screen readers for the vision-impaired) that I think it's more
sensible to set the process back to its default level of protection.

This precaution was never a fully effective protection anyway, due to
the race condition at process startup; the only properly effective
defence would have been to prevent malware running under the same user
ID as PuTTY in the first place, so in that sense, nothing has changed.
But people who want the arguable defence-in-depth advantage of the ACL
restriction can now turn it on with the '-restrict-acl' command-line
option, and it's up to them whether they can live with the assorted
inconveniences that come with it.

In the course of this change, I've centralised a bit more of the
restriction code into winsecur.c, to avoid repeating the error
handling in multiple places.

7 years agoTweak bounds checks in pageant_add_keyfile.
Simon Tatham [Mon, 23 Jan 2017 20:08:18 +0000 (20:08 +0000)]
Tweak bounds checks in pageant_add_keyfile.

When we're going through the response from an SSH agent we asked for a
list of keys, and processing the string lengths in the SSH-2 sequence
of (public blob, comment) pairs, we were adding 4 to each string
length, and although we checked if the result came out to a negative
value (if interpreted as a signed integer) or a positive one going
beyond the end of the response buffer, we didn't check if it wrapped
round to a positive value less than 4. As a result, if an agent
returned malformed data sent a length field of 0xFFFFFFFC, the pointer
would advance no distance at all through the buffer, and the next
iteration of the loop would check the same length field again.

(However, this would only consume CPU pointlessly for a limited time,
because the outer loop up to 'nkeys' would still terminate sooner or
later. Also, I don't think this can sensibly be classed as a serious
security hazard - it's arguably a borderline DoS, but it requires a
hostile SSH _agent_ if data of that type is to be sent on purpose, and
an untrusted SSH agent is not part of the normal security model!)

7 years agoRewrite agent forwarding to serialise requests.
Simon Tatham [Sun, 29 Jan 2017 19:40:38 +0000 (19:40 +0000)]
Rewrite agent forwarding to serialise requests.

The previous agent-forwarding system worked by passing each complete
query received from the input to agent_query() as soon as it was
ready. So if the remote client were to pipeline multiple requests,
then Unix PuTTY (in which agent_query() works asynchronously) would
parallelise them into many _simultaneous_ connections to the real
agent - and would not track which query went out first, so that if the
real agent happened to send its replies (to what _it_ thought were
independent clients) in the wrong order, then PuTTY would serialise
the replies on to the forwarding channel in whatever order it got
them, which wouldn't be the order the remote client was expecting.

To solve this, I've done a considerable rewrite, which keeps the
request stream in a bufchain, and only removes data from the bufchain
when it has a complete request. Then, if agent_query decides to be
asynchronous, the forwarding system waits for _that_ agent response
before even trying to extract the next request's worth of data from
the bufchain.

As an added bonus (in principle), this gives agent-forwarding channels
some actual flow control for the first time ever! If a client spams us
with an endless stream of rapid requests, and never reads its
responses, then the output side of the channel will run out of window,
which causes us to stop processing requests until we have space to
send responses again, which in turn causes us to stop granting extra
window on the input side, which serves the client right.

7 years agoMake asynchronous agent_query() requests cancellable.
Simon Tatham [Sun, 29 Jan 2017 20:24:15 +0000 (20:24 +0000)]
Make asynchronous agent_query() requests cancellable.

Now, instead of returning a boolean indicating whether the query has
completed or is still pending, agent_query() returns NULL to indicate
that the query _has_ completed, and if it hasn't, it returns a pointer
to a context structure representing the pending query, so that the
latter can be used to cancel the query if (for example) you later
decide you need to free the thing its callback was using as a context.

This should fix a potential race-condition segfault if you overload an
agent forwarding channel and then close it abruptly. (Which nobody
will be doing for sensible purposes, of course! But I ran across this
while stress-testing other aspects of agent forwarding.)

7 years agoRemove the commented-out WINDOWS_ASYNC_AGENT code.
Simon Tatham [Sun, 29 Jan 2017 20:24:09 +0000 (20:24 +0000)]
Remove the commented-out WINDOWS_ASYNC_AGENT code.

It's been commented out for ages because it never really worked, and
it's about to become further out of date when I make other changes to
the agent client code, so it's time to get rid of it before it gets in
the way.

If and when I do get round to supporting asynchronous agent requests
on Windows, it's now pretty clear to me that trying to coerce this
ghastly window-message IPC into the right shape is the wrong way, and
a better approach will be to make Pageant support a named-pipe based
alternative transport for its agent connections, and speaking the
ordinary stream-oriented agent protocol over that. Then Pageant will
be able to start adding interactive features (like confirmation
dialogs or on-demand decryption) with freedom to reply to multiple
simultaneous agent connections in whatever order it finds convenient.

7 years agoFix Makefile warning about circular empty.h dependency.
Simon Tatham [Sun, 29 Jan 2017 19:42:42 +0000 (19:42 +0000)]
Fix Makefile warning about circular empty.h dependency.

In commit be586d53b I made empty.h depend on $(allsources), which
unfortunately was defined so as to include empty.h. This was harmless,
because make just ignored the circular dependency, but annoying,
because it constantly mentioned that it was ignoring it.

7 years agoReport the right address in connection setup errors.
Simon Tatham [Sat, 28 Jan 2017 10:56:19 +0000 (10:56 +0000)]
Report the right address in connection setup errors.

backend_socket_log was generating the IP address in its error messages
by means of calling sk_getaddr(). But sk_getaddr only gets a SockAddr,
which may contain a whole list of candidate addresses; it doesn't also
get the information stored in the 'step' field of the Socket that was
actually trying to make the connection, which says _which_ of those
addresses we were in the middle of trying to connect to.

So now we construct a temporary SockAddr that points at the
appropriate one of the addresses, and use that for calls to plug_log
during connection setup.

7 years agoRework handling of asynchronous connect(2) errors on Unix.
Simon Tatham [Tue, 24 Jan 2017 22:30:44 +0000 (22:30 +0000)]
Rework handling of asynchronous connect(2) errors on Unix.

If connect() returns EINPROGRESS, then previously we would detect a
successful connection by the socket becoming selectable for writing,
and spot an unsuccessful one by an error code being returned on the
first attempt to read from it.

This isn't the right way to do it: the right way is to respond to the
initial writability notification by calling getsockopt(SO_ERROR) to
retrieve the error code (if any) from the completed connection
attempt. Doing it the old way had the problem that when the socket
became writable, we could sometimes already have written some of our
outgoing data to it before finding out that the connect attempt failed
- which meant we'd discard that data from the bufchain, and no longer
have it to send through a later successful connection to a different
candidate address.

7 years agoFix an integer overflow in get_ssh_string.
Simon Tatham [Wed, 25 Jan 2017 19:47:08 +0000 (19:47 +0000)]
Fix an integer overflow in get_ssh_string.

If the length field in the input data was so large that adding 4 to it
caused wraparound, the error check could fail to trigger. Fortunately,
this praticular get_ssh_string function is only used during private
key import from foreign file formats, so it won't be facing hostile
data.

7 years agoFix a memory leak in openssh_loadpub
Tim Kosse [Mon, 23 Jan 2017 18:10:40 +0000 (19:10 +0100)]
Fix a memory leak in openssh_loadpub

The line read from the input file was not freed after successfully
loading an OpenSSH key.

7 years agoFix a memory leak in rsakey_pubblob
Tim Kosse [Mon, 23 Jan 2017 18:04:50 +0000 (19:04 +0100)]
Fix a memory leak in rsakey_pubblob

The line read from the input file was not freed after successfully
loading an SSH1 key.

7 years agoFix resource leak in rsakey_pubblob
Tim Kosse [Mon, 23 Jan 2017 17:58:17 +0000 (18:58 +0100)]
Fix resource leak in rsakey_pubblob

The input file was not closed after successfully loading an SSH1 key.

7 years agoFix memory leak in bignum_from_decimal
Tim Kosse [Mon, 23 Jan 2017 17:55:20 +0000 (18:55 +0100)]
Fix memory leak in bignum_from_decimal

Intermediate result values were not freed.

7 years agoFix memory leak in ed25519_openssh_createkey
Tim Kosse [Mon, 23 Jan 2017 17:46:42 +0000 (18:46 +0100)]
Fix memory leak in ed25519_openssh_createkey

If q could not be read from the input blob, the allocated ec_key
structure was not freed.

7 years agoAdd error variable to loop condition
Tim Kosse [Mon, 23 Jan 2017 17:51:03 +0000 (18:51 +0100)]
Add error variable to loop condition

In case of connection errors before and during the handshake,
net_select_result is retrying with the next address of the server. It
however was immediately going to the last address as it was not
checking the return value of try_connect for all intermediate
addresses.

7 years agoWe routinely compile with both VS2003 and 2015.
Jacob Nevins [Mon, 23 Jan 2017 23:41:39 +0000 (23:41 +0000)]
We routinely compile with both VS2003 and 2015.

7 years agoIt's a new year.
Jacob Nevins [Mon, 23 Jan 2017 20:51:00 +0000 (20:51 +0000)]
It's a new year.

7 years agoFix misspelled redirect of the 64-bit installer.
Simon Tatham [Sat, 21 Jan 2017 15:29:50 +0000 (15:29 +0000)]
Fix misspelled redirect of the 64-bit installer.

The .htaccess written by Buildscr into the w64 directory was applying
a redirect from 'putty-installer.msi', but in fact the name by which
the website links to snapshot and prerelease installers in that
directory is 'putty-64bit-installer.msi'.

7 years agoRename the maps directory in release.pl.
Simon Tatham [Sat, 21 Jan 2017 15:17:03 +0000 (15:17 +0000)]
Rename the maps directory in release.pl.

The code that copies the link maps of the release Windows builds into
the place I store them for later debugging should now not
embarrassingly look in the wrong place when we make our first
post-VS2015 release.

7 years agoChecklist updates from the website revamp.
Simon Tatham [Sat, 31 Dec 2016 17:27:30 +0000 (17:27 +0000)]
Checklist updates from the website revamp.

I've now made a new section about how to turn on pre-release mode,
because although it's been carefully made trivial within the website
repo itself, there are still several things in other places I need to
edit.

Also added a note to myself to turn off nightly pre-release builds
after the release has gone out. I found on a previous occasion that my
build machine had been building them for months after they were
needed, which was harmless to the website but a waste of CPU!

7 years agoConditionalise the automake git-commit embedding.
Simon Tatham [Sat, 21 Jan 2017 14:57:31 +0000 (14:57 +0000)]
Conditionalise the automake git-commit embedding.

This arranges that the mechanism from the previous commit
automatically turns itself on and off depending on whether a .git
directory even exists (so it won't try to do anything in distribution
tarballs), and also arranges that it can be manually turned off by a
configure option (in case someone who _is_ building from a git
checkout finds it inconvenient for some reason I haven't thought of,
which seems quite plausible to me).

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.