]> asedeno.scripts.mit.edu Git - PuTTY.git/log
PuTTY.git
10 years agoAdd support for Windows named pipes.
Simon Tatham [Sun, 17 Nov 2013 14:04:01 +0000 (14:04 +0000)]
Add support for Windows named pipes.

This commit adds two new support modules, winnpc.c and winnps.c, which
deal respectively with being a client and server of a Windows named
pipe (which, in spite of what Unix programmers will infer from that
name, is actually closer to Windows's analogue of a Unix-domain
socket). Each one provides a fully featured Socket wrapper around the
hairy Windows named pipe API, so that the rest of the code base should
be able to use these interchangeably with ordinary sockets and hardly
notice the difference.

As part of this work, I've introduced a mechanism in winhandl.c to
permit it to store handles of event objects on behalf of other Windows
support modules and deal with passing them to applications' main event
loops as necessary. (Perhaps it would have been cleaner to split
winhandl.c into an event-object tracking layer analogous to uxsel, and
the handle management which is winhandl.c's proper job, but this is
less disruptive for the present.)

[originally from svn r10069]

10 years agoReplace the hacky 'OSSocket' type with a closure.
Simon Tatham [Sun, 17 Nov 2013 14:03:55 +0000 (14:03 +0000)]
Replace the hacky 'OSSocket' type with a closure.

The mechanism for constructing a new connection-type Socket when a
listening one receives an incoming connection previously worked by
passing a platform-specific 'OSSocket' type to the plug_accepting
function, which would then call sk_register to wrap it with a proper
Socket instance. This is less flexible than ideal, because it presumes
that only one kind of OS object might ever need to be turned into a
Socket. So I've replaced OSSocket throughout the code base with a pair
of parameters consisting of a function pointer and a context such that
passing the latter to the former returns the appropriate Socket; this
will permit different classes of listening Socket to pass different
function pointers.

In deference to the reality that OSSockets tend to be small integers
or pointer-sized OS handles, I've made the context parameter an
int/pointer union that can hold either of those directly, rather than
the usual approach of making it a plain 'void *' and requiring a
context structure to be dynamically allocated every time.

[originally from svn r10068]

10 years agoImplement freezing on Windows handle sockets.
Simon Tatham [Sun, 17 Nov 2013 14:03:48 +0000 (14:03 +0000)]
Implement freezing on Windows handle sockets.

That's been a FIXME in the code for ages, because it's difficult to
get winhandl.c to stop an already-started read from a handle (since
the read is a blocking system call running in a separate thread). But
I now realise it isn't absolutely necessary to do so - you can just
buffer one lot of data from winhandl and _then_ tell it to stop.

[originally from svn r10067]

10 years agoFactor out the HANDLE-to-Socket adapter from winproxy.c.
Simon Tatham [Sun, 17 Nov 2013 14:03:44 +0000 (14:03 +0000)]
Factor out the HANDLE-to-Socket adapter from winproxy.c.

It's now kept in a separate module, where it can be reused
conveniently for other kinds of Windows HANDLE that I want to wrap in
the PuTTY Socket abstraction - for example, the named pipes that I
shortly plan to use for the Windows side of connection-sharing IPC.

[originally from svn r10066]

10 years agoAdd a Socket implementation which just holds an error message.
Simon Tatham [Sun, 17 Nov 2013 14:03:36 +0000 (14:03 +0000)]
Add a Socket implementation which just holds an error message.

This isn't yet used, but I plan to use it in situations where you have
to report errors by returning a valid Socket on which the client wlil
call sk_socket_error, but in fact you notice the error _before_
instantiating your usual kind of Socket. The resulting Socket is
usable for nothing except reading out the error string and closing it.

[originally from svn r10065]

10 years agoMove SSH protocol enumerations out into ssh.h.
Simon Tatham [Sun, 17 Nov 2013 14:03:29 +0000 (14:03 +0000)]
Move SSH protocol enumerations out into ssh.h.

This permits packet type codes and other magic numbers to be accessed
from modules other than ssh.c.

[originally from svn r10064]

10 years agoMove cipher settings into their own config panel.
Simon Tatham [Sun, 17 Nov 2013 14:03:25 +0000 (14:03 +0000)]
Move cipher settings into their own config panel.

This makes room in the main SSH panel for new options about connection
sharing, which I'm shortly going to add.

[originally from svn r10063]

10 years agoClean up the semantics of the ssh_rportfwd structure.
Simon Tatham [Sun, 17 Nov 2013 14:03:21 +0000 (14:03 +0000)]
Clean up the semantics of the ssh_rportfwd structure.

It's now indexed by source hostname as well as source port (so that
separate requests for the server to listen on addr1:1234 and
addr2:1234 can be disambiguated), and also its destination host name
is dynamically allocated rather than a fixed-size buffer.

[originally from svn r10062]

10 years agoFind ToUnicodeEx() at run time, not load time.
Simon Tatham [Sun, 17 Nov 2013 14:03:20 +0000 (14:03 +0000)]
Find ToUnicodeEx() at run time, not load time.

This restores PuTTY's backward compatibility to versions of Windows
too old to have ToUnicodeEx in their system libraries, which was
accidentally broken in 0.63.

[originally from svn r10061]

10 years agoReplace GetQueueStatus with PeekMessage(PM_NOREMOVE).
Simon Tatham [Mon, 11 Nov 2013 23:01:47 +0000 (23:01 +0000)]
Replace GetQueueStatus with PeekMessage(PM_NOREMOVE).

A couple of users report that my recent reworking of the Windows
top-level message loop has led to messages occasionally being lost,
and MsgWaitForMultipleObjects blocking when it ought to have been
called with a zero timeout. I haven't been able to reproduce this
myself, but according to one reporter, PeekMessage(PM_NOREMOVE) is
effective at checking for a non-empty message queue in a way that
GetQueueStatus is not. Switch to using that instead. Thanks to Eric
Flumerfelt for debugging and testing help.

[originally from svn r10057]

10 years agoFix build failures on Ubuntu 13.10.
Simon Tatham [Sat, 26 Oct 2013 14:00:10 +0000 (14:00 +0000)]
Fix build failures on Ubuntu 13.10.

Automake now insists that we run AM_PROG_AR if we're going to build a
library, and AM_PROG_CC_C_O if we're going to build anything with
extra compile options. Those extra macros seem harmless in previous
versions of automake.

[originally from svn r10053]

10 years agoAvoid leaving unread Windows messages in the queue.
Simon Tatham [Fri, 25 Oct 2013 17:44:02 +0000 (17:44 +0000)]
Avoid leaving unread Windows messages in the queue.

Jochen Erwied points out that once you've used PeekMessage to remove
_one_ message from the message queue, MsgWaitForMultipleObjects will
consider the whole queue to have been 'read', or at least looked at
and deemed uninteresting, and so it will block until a further message
comes in. Hence, my change in r10040 which stops us from looping on
PeekMessage until the queue is empty has the effect of causing the
rest of the message queue not to be acted on until a new message comes
in to unblock it. Fix by checking if the queue is nonempty in advance
of calling MsgWaitForMultipleObjects, and if so, giving it a zero
timeout just as we do if there's a pending toplevel callback.

[originally from svn r10052]
[r10040 == 5c4ce2fadf23bff6f38155df44b5d6040cf80d26]

10 years agorandom_ref() should always increment the reference count.
Simon Tatham [Wed, 9 Oct 2013 18:38:35 +0000 (18:38 +0000)]
random_ref() should always increment the reference count.

No current PuTTY utility was calling random_ref more than once per run
(ssh.c and the two main PuTTYgen programs call it once each), but if
one ever does (or if derived code does), it will want the reference
count to actually work sensibly.

[originally from svn r10049]

10 years agoDon't pass WinSock error codes to strerror.
Simon Tatham [Wed, 9 Oct 2013 18:36:56 +0000 (18:36 +0000)]
Don't pass WinSock error codes to strerror.

Martin Prikryl helpfully points out that when I revamped the socket
error mechanism using toplevel callbacks, I also accidentally passed
the error code to the wrong function. Use winsock_error_string instead.

[originally from svn r10048]

10 years agoFix cut-and-paste errors in nonfatal() implementations.
Simon Tatham [Mon, 23 Sep 2013 14:35:08 +0000 (14:35 +0000)]
Fix cut-and-paste errors in nonfatal() implementations.

Unix GUI programs should not say 'Fatal Error' in the message box
title, and Plink should not destroy its logging context as a side
effect of printing a non-fatal error. Both appear to have been due to
inattentive cut and paste from the pre-existing fatal error functions.

[originally from svn r10044]

10 years agoOops! Remove a tight-looping diagnostic.
Simon Tatham [Sun, 15 Sep 2013 14:40:46 +0000 (14:40 +0000)]
Oops! Remove a tight-looping diagnostic.

I temporarily applied it as a means of testing the revised event loops
in r10040, and accidentally folded it into my final commit instead of
backing it out. Ahem.

[originally from svn r10042]
[r10040 == 5c4ce2fadf23bff6f38155df44b5d6040cf80d26]

10 years agoRemove the timed part of the terminal paste mechanism.
Simon Tatham [Sun, 15 Sep 2013 14:05:38 +0000 (14:05 +0000)]
Remove the timed part of the terminal paste mechanism.

In r10020 I carefully reimplemented using timing.c and callback.c the
same policy for large pastes that the previous code appeared to be
implementing ad-hoc, which included a 450ms delay between sending
successive lines of pasted text if no visible acknowledgment of the
just-sent line (in the form of a \n or \r) came back from the
application.

However, it turns out that that *wasn't* what the old code was doing.
It *would* have done that, but for the bug that it never actually set
the 'last_paste' variable, and never has done since it was first
introduced way back in r516! So the policy I thought had been in force
forever has in fact only been in force since I unwittingly fixed that
bug in r10020 - and it turns out to be a bad idea, breaking pastes
into vi in particular.

So I've removed the timed paste code completely, on the basis that
it's never actually worked and nobody seems to have been unhappy about
that. Now we still break large pastes into separate lines and send
them in successive top-level callbacks, and the user can still press a
key to interrupt a paste if they manage to catch it still going on,
but there's no attempted *delay* any more.

(It's possible that what I *really* ought to be doing is calling
back->sendbuffer() to see whether the backend is consuming the data
pasted so far, and if not, deferring the rest of the paste until the
send buffer becomes smaller. Then we could have pasting be delayed by
back-pressure from the recipient, and still manually interruptible
during that delay, but not have it delayed by anything else. But what
we have here should at least manage to be equivalent to the *actual*
rather than the intended old policy.)

[originally from svn r10041]
[r516 == 0d5d39064a0d078af47e3158313dd2b82bfd167c]
[r10020 == 7be9af74ec8b97f948d6b3d67ebaf1a97138da33]

10 years agoOnly run one toplevel callback per event loop iteration.
Simon Tatham [Sun, 15 Sep 2013 14:05:31 +0000 (14:05 +0000)]
Only run one toplevel callback per event loop iteration.

This change attempts to reinstate as a universal property something
which was sporadically true of the ad-hockery that came before
toplevel callbacks: that if there's a _very long_ queue of things to
be done through the callback mechanism, the doing of them will be
interleaved with re-checks of other event sources, which might (e.g.)
cause a flag to be set which makes the next callback decide not to do
anything after all.

[originally from svn r10040]

10 years agoHandle socket errors on half-open channels.
Simon Tatham [Sun, 8 Sep 2013 13:20:49 +0000 (13:20 +0000)]
Handle socket errors on half-open channels.

Anthony Ho reports that this can occur naturally in some situation
involving Windows 8 + IE 11 and dynamic port forwarding: apparently we
get through the SOCKS negotiation, send our CHANNEL_OPEN, and then
*immediately* suffer a local WSAECONNABORTED error before the server
has sent back its OPEN_CONFIRMATION or OPEN_FAILURE. In this situation
ssh2_channel_check_close was failing to notice that the channel didn't
yet have a valid server id, and sending out a CHANNEL_CLOSE anyway
containing 32 bits of uninitialised nonsense.

We now handle this by turning our half-open CHAN_SOCKDATA_DORMANT into
a half-open CHAN_ZOMBIE, which means in turn that our handler
functions for OPEN_CONFIRMATION and OPEN_FAILURE have to recognise and
handle that case, the former by immediately initiating channel closure
once we _do_ have the channel's server id to do it with.

[originally from svn r10039]

10 years agoPass an error message through to sshfwd_unclean_close.
Simon Tatham [Sun, 8 Sep 2013 07:14:56 +0000 (07:14 +0000)]
Pass an error message through to sshfwd_unclean_close.

We have access to one at every call site, so there's really no reason
not to send it through to ssh.c to be logged.

[originally from svn r10038]

10 years agoFix SSH2_MSG_CHANNEL_EXTENDED_DATA in logparse.
Simon Tatham [Sat, 7 Sep 2013 16:15:11 +0000 (16:15 +0000)]
Fix SSH2_MSG_CHANNEL_EXTENDED_DATA in logparse.

It looks as if it's never worked at all: it had a spurious second
printf, it completely forgot to allow for the uint32 type code that
SSH2_MSG_CHANNEL_DATA doesn't have, it accessed the channel state's
sequence number fields in a way that made no sense and didn't match
the rest of the program, *and* it misinvoked the file opening API. I
must have never had an occasion to test it.

[originally from svn r10037]

10 years agoMake logparse handle completely bogus channel numbers.
Simon Tatham [Sat, 7 Sep 2013 16:15:10 +0000 (16:15 +0000)]
Make logparse handle completely bogus channel numbers.

Previously it would throw a bunch of Perl undefined-variable-usage
warnings; now it cleanly detects the problem, dumps as much of the
message as it still reasonably can, and doesn't update any channel
states.

[originally from svn r10036]

10 years agoFix free of an uninitialised pointer.
Simon Tatham [Mon, 26 Aug 2013 11:55:56 +0000 (11:55 +0000)]
Fix free of an uninitialised pointer.

CHAN_AGENT channels need c->u.a.message to be either NULL or valid
dynamically allocated memory, because it'll be freed by
ssh_channel_destroy. This bug triggers if an agent forwarding channel
is opened and closed without having sent any queries.

[originally from svn r10032]

10 years agoFix handling of IPv6 dynamic forwardings.
Simon Tatham [Thu, 22 Aug 2013 17:45:26 +0000 (17:45 +0000)]
Fix handling of IPv6 dynamic forwardings.

During the Conf revamp, I changed the internal representation of
dynamic forwardings so that they were stored as the conceptually
sensible L12345=D rather than the old D12345, and added compensation
code to translate to the latter form for backwards-compatible data
storage and for OpenSSH-harmonised GUI display. Unfortunately I forgot
that keys in the forwarding data can also prefix the L/R with a
character indicating IPv4/IPv6, and my translations didn't take
account of that possibility. Fix them.

[originally from svn r10031]

10 years agoDon't run toplevel callbacks in modal dialogs.
Simon Tatham [Sun, 18 Aug 2013 10:56:20 +0000 (10:56 +0000)]
Don't run toplevel callbacks in modal dialogs.

Because some of them can call gtk_main_quit(), which completely
confuses the dialog box system.

[originally from svn r10029]

10 years agoSensibly enforce non-interactive rekeying.
Simon Tatham [Sun, 18 Aug 2013 06:48:20 +0000 (06:48 +0000)]
Sensibly enforce non-interactive rekeying.

We now only present the full set of host key algorithms we can handle
in the first key exchange. In subsequent rekeys, we present only the
host key algorithm that we agreed on the previous time, and then we
verify the host key by simply enforcing that it's exactly the same as
the one we saw at first and disconnecting rudely if it isn't.

[originally from svn r10027]

10 years agoMake calling term_nopaste() a cross-platform feature.
Simon Tatham [Sat, 17 Aug 2013 16:06:40 +0000 (16:06 +0000)]
Make calling term_nopaste() a cross-platform feature.

It was one of those things that went in ages ago on Windows and never
got replicated in the Unix front end. And it needn't be: ldisc.c is a
perfect place to put it, since it knows which of the data it's sending
is based on a keystroke and which is automatically generated, and it
also has access to the terminal context. So now a keypress can
interrupt a runaway paste on all platforms.

[originally from svn r10025]

10 years agoRevamp Windows pending_netevent using toplevel callbacks.
Simon Tatham [Sat, 17 Aug 2013 16:06:35 +0000 (16:06 +0000)]
Revamp Windows pending_netevent using toplevel callbacks.

This greatly simplifies the process of calling select_result() from
the top level after receiving WM_NETEVENT.

[originally from svn r10024]

10 years agoRevamp net_pending_errors using toplevel callbacks.
Simon Tatham [Sat, 17 Aug 2013 16:06:27 +0000 (16:06 +0000)]
Revamp net_pending_errors using toplevel callbacks.

Again, I've removed the special-purpose ad-hockery from the assorted
front end message loops that dealt with deferred handling of socket
errors, and instead uxnet.c and winnet.c arrange that for themselves
by calling the new general top-level callback mechanism.

[originally from svn r10023]

10 years agoRevamp GTK's session close handling using toplevel callbacks.
Simon Tatham [Sat, 17 Aug 2013 16:06:22 +0000 (16:06 +0000)]
Revamp GTK's session close handling using toplevel callbacks.

Instead of having a special GTK idle function for dealing with session
closing, I now use the new top-level callback mechanism which is
slightly simpler for calling a one-off function.

Also in this commit, I've arranged for connection_fatal to queue a
call to the same session close function after displaying the message
box, with the effect that now all the same processing takes place no
matter whether the session closes cleanly or uncleanly - e.g. the SSH
specials submenu is cleaned out, as it should be.

[originally from svn r10022]

10 years agoRevamp Windows's close_session() using toplevel callbacks.
Simon Tatham [Sat, 17 Aug 2013 16:06:18 +0000 (16:06 +0000)]
Revamp Windows's close_session() using toplevel callbacks.

Instead of setting a must_close_session flag and having special code
in the message loop to check it, we'll schedule the call to
close_session using the new top-level callback system.

[originally from svn r10021]

10 years agoRevamp the terminal paste mechanism using toplevel callbacks.
Simon Tatham [Sat, 17 Aug 2013 16:06:12 +0000 (16:06 +0000)]
Revamp the terminal paste mechanism using toplevel callbacks.

I've removed the ad-hoc front-end bodgery in the Windows and GTK ports
to arrange for term_paste to be called at the right moments, and
instead, terminal.c itself deals with knowing when to send the next
chunk of pasted data using a combination of timers and the new
top-level callback mechanism.

As a happy side effect, it's now all in one place so I can actually
understand what it's doing! It turns out that what all that confusing
code was up to is: send a line of pasted data, and delay sending the
next line until either a CR or LF is returned from the server
(typically indicating that the pasted text has been received and
echoed) or 450ms elapse, whichever comes first.

[originally from svn r10020]

10 years agoAdd a general way to request an immediate top-level callback.
Simon Tatham [Sat, 17 Aug 2013 16:06:08 +0000 (16:06 +0000)]
Add a general way to request an immediate top-level callback.

This is a little like schedule_timer, in that the callback you provide
will be run from the top-level message loop of whatever application
you're in; but unlike the timer mechanism, it will happen
_immediately_.

The aim is to provide a general way to avoid re-entrance of code, in
cases where just _doing_ the thing you want done is liable to trigger
a confusing recursive call to the function in which you came to the
decision to do it; instead, you just request a top-level callback at
the message loop's earliest convenience, and do it then.

[originally from svn r10019]

10 years agoSebastian Kuschel reports that pfd_closing can be called for a socket
Simon Tatham [Thu, 15 Aug 2013 06:42:36 +0000 (06:42 +0000)]
Sebastian Kuschel reports that pfd_closing can be called for a socket
error with pr->c NULL, in which case calling sshfwd_unclean_close on
it will dereference NULL and segfault. Write an alternative error
handling path for that possibility.

(I don't know if it's the only way, but one way this can happen is if
you're doing dynamic forwarding and the socket error occurs during
SOCKS negotiation, in which case no SSH channel has been set up yet
because we haven't yet found out what we want to put in the
direct-tcpip channel open message.)

[originally from svn r10018]

10 years agoIt turns out I was a little over-strict in my handling of EOF in
Simon Tatham [Tue, 13 Aug 2013 06:46:51 +0000 (06:46 +0000)]
It turns out I was a little over-strict in my handling of EOF in
pscp.c when I did the big revamp in r9279: I assumed that in any SCP
connection we would be the first to send EOF, but in fact this isn't
true - doing downloads with old-SCP, EOF is initiated by the server,
so we were spuriously reporting an error for 'unexpected' EOF when
everything had gone fine. Thanks to Nathan Phelan for the report.

[originally from svn r10016]
[r9279 == 947962e0b95e10151c186048a8b5cc2fb425838c]

10 years agosbcsgen.pl uses 'select' to point Perl at a different default output
Simon Tatham [Thu, 8 Aug 2013 17:22:07 +0000 (17:22 +0000)]
sbcsgen.pl uses 'select' to point Perl at a different default output
handle. Revert that when we hackily call it from mkfiles.pl, so that
if I have a need to insert diagnostics in the latter they won't go
into the end of sbcsdat.c.

[originally from svn r10013]

10 years agoRevert the default for font bolding style back to using colours rather
Simon Tatham [Wed, 7 Aug 2013 06:22:52 +0000 (06:22 +0000)]
Revert the default for font bolding style back to using colours rather
than fonts. I broke this in r9559 when I added the option for 'both',
because the internal representation got offset by one so as to change
from a boolean to two bitfields and I must have confused myself about
what the default should be.

[originally from svn r10008]
[r9559 == bc6e0952ef1c27c577318ee3c0883c7823c7005b]

10 years agoBump version number prior to tagging 0.63. 0.63
Simon Tatham [Tue, 6 Aug 2013 17:09:07 +0000 (17:09 +0000)]
Bump version number prior to tagging 0.63.

[originally from svn r9998]

10 years agoOne more defensive assert, just to be sure.
Simon Tatham [Tue, 6 Aug 2013 16:45:49 +0000 (16:45 +0000)]
One more defensive assert, just to be sure.

[originally from svn r9997]

10 years agoThe bignum code has two representations of zero, since
Simon Tatham [Mon, 5 Aug 2013 19:50:51 +0000 (19:50 +0000)]
The bignum code has two representations of zero, since
bn_restore_invariant (and the many loops that duplicate it) leaves a
single zero word in a bignum representing 0, whereas the constant
'Zero' does not have any data words at all. Cope with this in
bignum_cmp.

(It would be a better plan to decide on one representation and stick
with it, but this is the less disruptive fix for the moment.)

[originally from svn r9996]

10 years agoAdd some more precautionary assertions, just in case anything wildly
Simon Tatham [Mon, 5 Aug 2013 19:50:47 +0000 (19:50 +0000)]
Add some more precautionary assertions, just in case anything wildly
out of range manages to get past other recent fixes.

[originally from svn r9995]

10 years agoBelatedly update the copyright year to 2013.
Jacob Nevins [Mon, 5 Aug 2013 15:15:17 +0000 (15:15 +0000)]
Belatedly update the copyright year to 2013.

[originally from svn r9993]
[this svn revision also touched putty-website]

10 years agoFix memory leaks in the new error return from modinv.
Simon Tatham [Sun, 4 Aug 2013 22:33:50 +0000 (22:33 +0000)]
Fix memory leaks in the new error return from modinv.

[originally from svn r9992]

10 years agoSpot when we didn't successfully create an RSA public key from a
Simon Tatham [Sun, 4 Aug 2013 19:34:10 +0000 (19:34 +0000)]
Spot when we didn't successfully create an RSA public key from a
public blob, and return a proper error in that situation rather than a
struct with unhelpful NULLs in.

[originally from svn r9991]

10 years agoMake modinv able to return NULL if its inputs are not coprime, and
Simon Tatham [Sun, 4 Aug 2013 19:34:07 +0000 (19:34 +0000)]
Make modinv able to return NULL if its inputs are not coprime, and
check for that return value everywhere it is used.

[originally from svn r9990]

10 years agoAvoid trying to take the modular inverse of zero in response to a
Simon Tatham [Sun, 4 Aug 2013 19:34:00 +0000 (19:34 +0000)]
Avoid trying to take the modular inverse of zero in response to a
sufficiently silly DSA signature.

[originally from svn r9989]

10 years agoAnother couple of memory leaks.
Simon Tatham [Sun, 4 Aug 2013 19:33:57 +0000 (19:33 +0000)]
Another couple of memory leaks.

[originally from svn r9988]

10 years agoMore consistently defend against division by zero with assertions. We
Simon Tatham [Sun, 4 Aug 2013 19:33:53 +0000 (19:33 +0000)]
More consistently defend against division by zero with assertions. We
now check that all the modular functions (modpow, modinv, modmul,
bigdivmod) have nonzero moduli, and that modinv also has a nonzero
thing to try to invert.

[originally from svn r9987]

10 years agoValidate newly created DSA keys more carefully. Don't want a structure
Simon Tatham [Sun, 4 Aug 2013 19:33:49 +0000 (19:33 +0000)]
Validate newly created DSA keys more carefully. Don't want a structure
half-filled with null pointers.

[originally from svn r9986]

10 years agoRemove some redundant null-pointer checks from code that must have
Simon Tatham [Sun, 4 Aug 2013 19:33:46 +0000 (19:33 +0000)]
Remove some redundant null-pointer checks from code that must have
been written before I wrote a never-failing snew.

[originally from svn r9985]

10 years agoSanitise freeing of DSA keys.
Simon Tatham [Sun, 4 Aug 2013 19:33:43 +0000 (19:33 +0000)]
Sanitise freeing of DSA keys.

[originally from svn r9984]

10 years agoReinstate a piece of code accidentally removed in r9214, where Windows
Simon Tatham [Sun, 4 Aug 2013 19:32:10 +0000 (19:32 +0000)]
Reinstate a piece of code accidentally removed in r9214, where Windows
PuTTY does not trim a colon suffix off the hostname if it contains
_more than one_ colon. This allows IPv6 literals to be entered.

(Really we need to do a much bigger revamp of all uses of hostnames to
arrange that square-bracketed IPv6 literals work consistently, but
this at least removes a regression over 0.62.)

[originally from svn r9983]
[r9214 == a1f3b7a358adaa7c2a98359cd0373aa823eeb14b]

10 years agoRaise the default scrollback from 200 to 2000 lines. The former was
Simon Tatham [Fri, 2 Aug 2013 22:33:40 +0000 (22:33 +0000)]
Raise the default scrollback from 200 to 2000 lines. The former was
not so silly in the 1990s and before I implemented scrollback
compression, but it's been a ridiculously low default for a while now.

[originally from svn r9982]

10 years agoFound a lot of places in sshbn.c where for-loops zeroing out memory
Simon Tatham [Fri, 2 Aug 2013 19:51:36 +0000 (19:51 +0000)]
Found a lot of places in sshbn.c where for-loops zeroing out memory
just before freeing it really ought to be smemclrs.

[originally from svn r9981]

10 years agoVerify RSA keys created by rsa2_openssh_createkey.
Simon Tatham [Fri, 2 Aug 2013 06:28:05 +0000 (06:28 +0000)]
Verify RSA keys created by rsa2_openssh_createkey.

[originally from svn r9980]

10 years agoReplace some 'sfree' calls of bignums with the proper 'freebn'.
Simon Tatham [Fri, 2 Aug 2013 06:28:00 +0000 (06:28 +0000)]
Replace some 'sfree' calls of bignums with the proper 'freebn'.

[originally from svn r9979]

10 years agoAdd some missing bounds checks in signature verification routines.
Simon Tatham [Fri, 2 Aug 2013 06:27:56 +0000 (06:27 +0000)]
Add some missing bounds checks in signature verification routines.

[originally from svn r9978]

10 years agoFix an array-size bug in modmul, and add some tests for it.
Simon Tatham [Fri, 2 Aug 2013 06:27:54 +0000 (06:27 +0000)]
Fix an array-size bug in modmul, and add some tests for it.

[originally from svn r9977]

10 years agoRemove one of the frees added in r9916. stat_name points to somewhere
Simon Tatham [Mon, 29 Jul 2013 17:47:33 +0000 (17:47 +0000)]
Remove one of the frees added in r9916. stat_name points to somewhere
within the same string that destfname points to the start of, so
freeing it causes at best a double-free of destfname and more likely a
free of something that isn't even the start of an allocated block.

[originally from svn r9974]
[r9916 == cc4f38df148c84183efce644cd48f822233b962a]

10 years agoAdd an assortment of missing consts I've just noticed.
Simon Tatham [Sat, 27 Jul 2013 18:35:48 +0000 (18:35 +0000)]
Add an assortment of missing consts I've just noticed.

[originally from svn r9972]

10 years agoGet rid of the variable 'advapi' in Pageant's WinMain, which was never
Simon Tatham [Wed, 24 Jul 2013 19:18:06 +0000 (19:18 +0000)]
Get rid of the variable 'advapi' in Pageant's WinMain, which was never
actually used for anything sensible and could have been freed while
containing nonsense at program end.

[originally from svn r9971]

10 years agoBack out r9964. I wasn't paying attention: every control is in the
Simon Tatham [Mon, 22 Jul 2013 19:56:04 +0000 (19:56 +0000)]
Back out r9964. I wasn't paying attention: every control is in the
byid tree but not all of them are in the byctrl tree.

[originally from svn r9970]
[r9964 == b3afa10aa736600752fc215da2662d861f26b3be]

10 years agoAdd a bob script to do Coverity scanning.
Simon Tatham [Mon, 22 Jul 2013 19:56:00 +0000 (19:56 +0000)]
Add a bob script to do Coverity scanning.

[originally from svn r9969]

10 years agoFix a few more memory and resource leaks.
Simon Tatham [Mon, 22 Jul 2013 19:55:55 +0000 (19:55 +0000)]
Fix a few more memory and resource leaks.

[originally from svn r9968]

10 years agoRemove the variable 'bufused', which came over from winnet.c in
Simon Tatham [Mon, 22 Jul 2013 19:55:53 +0000 (19:55 +0000)]
Remove the variable 'bufused', which came over from winnet.c in
mistaken cut and paste and is just a bug.

[originally from svn r9967]

10 years agoIncrease FONT_MAXNO from 0x2f to 0x40, to ensure the fonts[] array
Simon Tatham [Mon, 22 Jul 2013 07:12:31 +0000 (07:12 +0000)]
Increase FONT_MAXNO from 0x2f to 0x40, to ensure the fonts[] array
includes every possible combination of the font bitfields, in
particular ATTR_OEM|ATTR_NARROW.

[originally from svn r9966]

10 years agoCorrect an inequality sign causing the bounds check in Windows
Simon Tatham [Mon, 22 Jul 2013 07:12:26 +0000 (07:12 +0000)]
Correct an inequality sign causing the bounds check in Windows
palette_set() to be bogus. Fortunately, this isn't exploitable through
the terminal emulator, because the palette escape sequence parser
contains its own bounds check before even calling palette_set().

While I'm at it, fix the same goof in the OS X version! That port is
more or less abandoned, but that's no excuse for leaving obviously
wrong code lying around.

[originally from svn r9965]

10 years agoMissing assert.
Simon Tatham [Mon, 22 Jul 2013 07:12:21 +0000 (07:12 +0000)]
Missing assert.

[originally from svn r9964]

10 years agoReplace the type-checking COMPTR macro with my current idea of best
Simon Tatham [Mon, 22 Jul 2013 07:12:15 +0000 (07:12 +0000)]
Replace the type-checking COMPTR macro with my current idea of best
practice in type-check macros.

[originally from svn r9963]

10 years agoAdd missing casts in arguments to ctype functions.
Simon Tatham [Mon, 22 Jul 2013 07:12:10 +0000 (07:12 +0000)]
Add missing casts in arguments to ctype functions.

[originally from svn r9962]

10 years agoRationalise null pointer checks in both decode_codepage functions, so
Simon Tatham [Mon, 22 Jul 2013 07:12:05 +0000 (07:12 +0000)]
Rationalise null pointer checks in both decode_codepage functions, so
that decode_codepage(NULL) and decode_codepage("") both return the
default character set.

[originally from svn r9961]

10 years agoFix a double error handling goof in the winstore side of the jump list
Simon Tatham [Mon, 22 Jul 2013 07:11:58 +0000 (07:11 +0000)]
Fix a double error handling goof in the winstore side of the jump list
support: transform_jumplist_registry should give its caller
dynamically allocated data if and only if it returns JUMPLISTREG_OK,
and get_jumplist_registry_entries should test the return value against
JUMPLISTREG_OK rather than a value from a totally different enum.

[originally from svn r9960]

10 years agoAnother big batch of memory leak fixes, again mostly on error paths.
Simon Tatham [Mon, 22 Jul 2013 07:11:54 +0000 (07:11 +0000)]
Another big batch of memory leak fixes, again mostly on error paths.
The most interesting one is printer_add_enum, which I've modified to
take a char ** rather than a char * so that it can both realloc its
input buffer _and_ return NULL to indicate error.

[originally from svn r9959]

10 years agoAdd a missing null pointer check in one of the dialog box functions.
Simon Tatham [Mon, 22 Jul 2013 07:11:48 +0000 (07:11 +0000)]
Add a missing null pointer check in one of the dialog box functions.

[originally from svn r9958]

10 years agoReport an error if deleting a random seed file fails.
Simon Tatham [Mon, 22 Jul 2013 07:11:44 +0000 (07:11 +0000)]
Report an error if deleting a random seed file fails.

(This has also required me to add a currently unused nonfatal() to
PuTTYgen, since although PuTTYgen won't actually try to delete
putty.rnd, it does link in winstore.c as a whole.)

[originally from svn r9957]

10 years agoInvent a win_strerror() function which behaves as much like Unix
Simon Tatham [Mon, 22 Jul 2013 07:11:39 +0000 (07:11 +0000)]
Invent a win_strerror() function which behaves as much like Unix
strerror as I can arrange, wrapping up all the ugly FormatMessage
nonsense and caching previously looked-up messages for reuse so that
callers can treat them as static.

[originally from svn r9956]

10 years agoRework keylist_update() to fix both a buffer-size limitation and a
Simon Tatham [Mon, 22 Jul 2013 07:11:35 +0000 (07:11 +0000)]
Rework keylist_update() to fix both a buffer-size limitation and a
memory leak.

[originally from svn r9955]

10 years agoInitialise 'psa' to NULL on every code path in the Pageant client
Simon Tatham [Sun, 21 Jul 2013 11:01:22 +0000 (11:01 +0000)]
Initialise 'psa' to NULL on every code path in the Pageant client
code, fixing a potential segfault when compiling with -DNO_SECURITY.

[originally from svn r9954]

10 years agoIf the SSH server sends us CHANNEL_CLOSE for a channel on which we're
Simon Tatham [Sun, 21 Jul 2013 10:12:58 +0000 (10:12 +0000)]
If the SSH server sends us CHANNEL_CLOSE for a channel on which we're
sitting on a pile of buffered data waiting for WINDOW_ADJUSTs, we
should throw away that buffered data, because the CHANNEL_CLOSE tells
us that we won't be receiving those WINDOW_ADJUSTs, and if we hang on
to the data and keep trying then it'll prevent ssh_channel_try_eof
from sending the CHANNEL_EOF which is a prerequisite of sending our
own CHANNEL_CLOSE.

[originally from svn r9953]

10 years agoAdd '.so' to the list of file extensions cleared up by 'make clean' in
Simon Tatham [Sun, 21 Jul 2013 09:16:37 +0000 (09:16 +0000)]
Add '.so' to the list of file extensions cleared up by 'make clean' in
Makefile.cyg, since if you're building against Winelib it will
generate one of those alongside each .exe file.

[originally from svn r9952]

10 years agoCompletely remove the 'frozen_readable' mechanism from uxnet.c. It
Simon Tatham [Sun, 21 Jul 2013 07:40:36 +0000 (07:40 +0000)]
Completely remove the 'frozen_readable' mechanism from uxnet.c. It
parallels a similar mechanism in winnet.c and came over by copy and
paste, but is pointless in the Unix networking API.

On Windows, if you're using a mechanism such as WSAAsyncSelect which
delivers readability notifications as messages rather than return
values from a system call, you only get notified that a socket is
readable once - it remembers that it's told you, and doesn't tell you
again until after you've done a read. So in the case where we
intentionally stop reading from a socket because our local buffer is
full, and later want to start reading again, we do a read from the
socket with MSG_PEEK set, and that clears Windows's flag and tells it
to start sending us readability notifications again.

On Unix, select() and friends didn't do anything so strange in the
first place, so the whole mechanism is unnecessary.

[originally from svn r9951]

10 years agoFix error checking in uxstore.c: add a missing check, and fix a
Simon Tatham [Sun, 21 Jul 2013 07:40:30 +0000 (07:40 +0000)]
Fix error checking in uxstore.c: add a missing check, and fix a
mis-cut-and-pasted one.

[originally from svn r9950]

10 years agoWhen I turned fcntls into noncloexecs in r9940, I missed one.
Simon Tatham [Sun, 21 Jul 2013 07:40:28 +0000 (07:40 +0000)]
When I turned fcntls into noncloexecs in r9940, I missed one.

[originally from svn r9949]
[r9940 == b4268722196a3d93183252584b86cbb719187a38]

10 years agoTwo more memory leak fixes, on error paths I didn't spot in r9919.
Simon Tatham [Sun, 21 Jul 2013 07:40:26 +0000 (07:40 +0000)]
Two more memory leak fixes, on error paths I didn't spot in r9919.

[originally from svn r9948]
[r9919 == ea301bdd9b892a5e70692f82f5c0b98bd585e775]

10 years agoFix a null-dereference introduced by another mis-fix in r9919.
Simon Tatham [Sat, 20 Jul 2013 13:15:20 +0000 (13:15 +0000)]
Fix a null-dereference introduced by another mis-fix in r9919.

[originally from svn r9946]
[r9919 == ea301bdd9b892a5e70692f82f5c0b98bd585e775]

10 years agoFix leak of 'fname' introduced by the rewrite of write_random_seed in
Simon Tatham [Sat, 20 Jul 2013 13:15:16 +0000 (13:15 +0000)]
Fix leak of 'fname' introduced by the rewrite of write_random_seed in
r9933.

[originally from svn r9945]
[r9933 == 2854ae1f33fe16124830b0cc3ac3ca843cd8ce9d]

10 years agoAnother two mis-fixes from r9919: when we sfree(line) on exit from the
Simon Tatham [Sat, 20 Jul 2013 13:15:11 +0000 (13:15 +0000)]
Another two mis-fixes from r9919: when we sfree(line) on exit from the
ssh.com and OpenSSH key import loops, we should also null it out so
that the cleanup path doesn't try to re-free the same pointer.

[originally from svn r9944]
[r9919 == ea301bdd9b892a5e70692f82f5c0b98bd585e775]

10 years agoRedo a mis-fix of a memory leak in r9919: I added sfree(data)
Simon Tatham [Sat, 20 Jul 2013 13:15:10 +0000 (13:15 +0000)]
Redo a mis-fix of a memory leak in r9919: I added sfree(data)
immediately after conf_deserialise in the Duplicate Session receiver,
whereas I should have put it after the subsequent loop that extracts
the pty argv if any.

[originally from svn r9943]
[r9919 == ea301bdd9b892a5e70692f82f5c0b98bd585e775]

10 years agoSwitch to translating keystrokes using ToUnicodeEx rather than
Simon Tatham [Sat, 20 Jul 2013 11:31:24 +0000 (11:31 +0000)]
Switch to translating keystrokes using ToUnicodeEx rather than
ToAsciiEx, where possible.

This enables support for keys which generate Unicode characters that
aren't in the system code page, which seems to me like a perverse way
for Windows to have set up the system code page but apparently does
happen, e.g. (I'm told) U+0219 and U+021B on Romanian keyboards.

Patch mostly due to Andrei Damian-Fekete.

[originally from svn r9942]

10 years agoBeen meaning to get round to this for a while: use CryptGenRandom to
Simon Tatham [Sat, 20 Jul 2013 08:34:54 +0000 (08:34 +0000)]
Been meaning to get round to this for a while: use CryptGenRandom to
gather extra entropy at Windows PuTTY startup time. (It's only used as
one of the inputs to PuTTY's internal entropy pool, so nobody is
required to trust it.)

[originally from svn r9941]

10 years agoCentralise calls to fcntl into functions that carefully check the
Simon Tatham [Fri, 19 Jul 2013 18:10:02 +0000 (18:10 +0000)]
Centralise calls to fcntl into functions that carefully check the
error returns.

[originally from svn r9940]

10 years agoAdd an error check to every setsockopt call in uxnet.c.
Simon Tatham [Fri, 19 Jul 2013 17:45:01 +0000 (17:45 +0000)]
Add an error check to every setsockopt call in uxnet.c.

[originally from svn r9939]

10 years agoAdd some conditionally-compilable diagnostics to the RNG. I got
Simon Tatham [Fri, 19 Jul 2013 17:44:58 +0000 (17:44 +0000)]
Add some conditionally-compilable diagnostics to the RNG. I got
briefly worried that it might not be doing what I thought it was
doing, but examining these diagnostics shows that it is after all, and
now I've written them it would be a shame not to keep them for future
use.

[originally from svn r9938]

10 years agoBetter error reporting when failing to save a session.
Simon Tatham [Fri, 19 Jul 2013 17:44:53 +0000 (17:44 +0000)]
Better error reporting when failing to save a session.

[originally from svn r9937]

10 years agoAdd some missing calls to cleanup_exit.
Simon Tatham [Fri, 19 Jul 2013 17:44:47 +0000 (17:44 +0000)]
Add some missing calls to cleanup_exit.

[originally from svn r9936]

10 years agoRun the random pool setup and teardown functions with random_active
Simon Tatham [Fri, 19 Jul 2013 17:44:42 +0000 (17:44 +0000)]
Run the random pool setup and teardown functions with random_active
nonzero rather than zero.

[originally from svn r9935]

10 years agoReport errors in store_host_key too.
Simon Tatham [Fri, 19 Jul 2013 17:44:38 +0000 (17:44 +0000)]
Report errors in store_host_key too.

[originally from svn r9934]

10 years agoAdd proper error reports in write_random_seed, via the new 'nonfatal'
Simon Tatham [Fri, 19 Jul 2013 17:44:33 +0000 (17:44 +0000)]
Add proper error reports in write_random_seed, via the new 'nonfatal'
error reporting function.

[originally from svn r9933]

10 years agoAdd a nonfatal() function everywhere, to be used for reporting things
Simon Tatham [Fri, 19 Jul 2013 17:44:28 +0000 (17:44 +0000)]
Add a nonfatal() function everywhere, to be used for reporting things
that the user really ought to know but that are not actually fatal to
continued operation of PuTTY or a single network connection.

[originally from svn r9932]

10 years agoAdd a missing error check in pterm's child-process setup. Shouldn't
Simon Tatham [Fri, 19 Jul 2013 17:44:22 +0000 (17:44 +0000)]
Add a missing error check in pterm's child-process setup. Shouldn't
really fail, but might as well be careful.

[originally from svn r9931]