Граф коммитов

5731 Коммитов

Автор SHA1 Сообщение Дата
Simon Tatham 29cb7e40eb GTK: fix handling of delete event in Change Settings dialog.
If the user closes the Change Settings dialog box using the close
button provided by the window manager (or some analogous thing that
generates the same X11 event) instead of using the Cancel button
within the dialog itself, then after_change_settings_dialog() gets
called with retval < 0, which triggers an early return path in which
we forget to call unregister_dialog(), and as a result, assertions
fail all over the place the _next_ time you try to put up a Change
Settings dialog.

Also, the early return causes ctx.newconf to be memory-leaked. So
rather than just moving the unregister_dialog() call to above the
early return, a better fix is to remove the early return completely,
and simply treat retval<0 the same as retval==0: it doesn't matter
_how_ the user closed the config box without committing the changes,
it only matters that they did.
2019-06-03 19:05:00 +01:00
Jacob Nevins 45be166be3 Note Pentium 4+ processor requirement.
(At least, that's what the Clang bog brush option -### says it's
building with.)
2019-05-12 22:23:48 +01:00
Simon Tatham 7119f87542 Uppity: fill in some missing end-of-session handling.
I needed to send a server-side disconnect message in a test just now,
which caused me to notice that I'd never got round to filling in
ssh_proto_error properly. Now I've done that, and added the associated
machinery for waiting for the remote EOF and winding up the SSH
connection.

The rest of the error functions are still stubs, though.
2019-05-10 10:49:20 +01:00
Simon Tatham 64a9b3ed67 Print 'instruction' field in keyboard-interactive auth.
When I reworked this code to make it strbuf-based, I apparently forgot
to copy the contents of one particular strbuf into the prompts_t.
2019-05-10 10:26:42 +01:00
Simon Tatham 4135e5d295 pscp: clear act->buf after receiving 'T' command.
Without this missing line, if you tried to download a file in SCP mode
using the -p option, the payload of the 'T' command (file times) would
still be sitting in act->buf when we went back round the loop, so the
payload of the followup 'C' or 'D' would be appended to it, leading to
a massive misparse and a complaint about illegal file renaming.
2019-05-08 08:30:10 +01:00
Simon Tatham 57c45c620f Uppity: print a startup message.
When I start Uppity in listening mode, it's useful to have it
acknowledge that it _has_ started up in that mode, and isn't (for
example) stuck somewhere in my local wrapper script.
2019-05-08 08:28:02 +01:00
Simon Tatham 1d733808c3 Missing piece of the previous commit.
Ahem. I was sure I'd hit save!
2019-05-05 20:43:16 +01:00
Simon Tatham 03aeabfbea Use a proper PRNG for GTK askpass.
Coverity complained that it was wrong to use rand() in a security
context, and although in this case it's _very_ marginal, I can't
actually disagree that the choice of which light to light up to avoid
giving information about passphrase length is a security context.

So, no more rand(); instead we instantiate a shiny Fortuna PRNG
instance, seed it in more or less the usual way, and use that as an
overkill-level method of choosing which light to light up next.

(Acknowledging that this is a slightly unusual application and less
critical than most, I don't actually put the passphrase characters
themselves into the PRNG, and I don't use a random-seed file.)
2019-05-05 20:28:00 +01:00
Simon Tatham 4fb20b15f3 Move random_save_seed() into sshrand.c.
It's identical in uxnoise and winnoise, being written entirely in
terms of existing cross-platform functions. Might as well centralise
it into sshrand.c.
2019-05-05 20:28:00 +01:00
Simon Tatham 5f35f5b4ac testsc.c: fix further memory leaks.
These were spotted by Leak Sanitiser rather than Coverity: it reported
them while I was checking the fixes for Coverity-spotted issues.
2019-05-05 10:25:01 +01:00
Simon Tatham 2b1e0a5e05 GSS kex: remove spurious no-op assignment.
Coverity points out that under a carefully checked compound condition,
we assign s->gss_cred_expiry to itself. :-)

Before commit 2ca0070f8 split the SSH code into separate modules, that
assignment read 'ssh->gss_cred_expiry = s->gss_cred_expiry', and the
point was that the value had to be copied out of the private state of
the transport-layer coroutine into the general state of the SSH
protocol as a whole so that ssh2_timer() (or rather, ssh2_gss_update,
called from ssh2_timer) could check it.

But now that timer function is _also_ local to the transport layer,
and shares the transport coroutine's state. So on the one hand, we
could just remove that assignment, folding the two variables into one;
on the other hand, we could reinstate the two variables and the
explicit 'commit' action that copies one into the other. The question
is, which?

Any _successful_ key exchange must have gone through that commit step
of the kex that copied the one into the other. And an unsuccessful key
exchange always aborts the whole SSH connection - there's nothing in
the SSH transport protocol that allows recovering from a failed rekey
by carrying on with the previous session keys. So if I made two
variables, then between key exchanges, they would always have the same
value anyway.

So the only effect of the separation between those variables is
_during_ a GSS key exchange: should the version of gss_cred_expiry
checked by the timer function be the new one, or the old one?

This can only make a difference if a timer goes off _during_ a rekey,
and happens to notice that the GSS credentials have expired. And
actually I think it's mildly _better_ if that checks the new expiry
time rather than the old one - otherwise, the timer routine would set
the flag indicating a need for another rekey, when actually the
currently running one was going to get the job done anyway.

So, in summary, I think conflating those two variables is actually an
improvement to the code. I did it by accident, but if I'd realised, I
would have done the same thing on purpose!

Hence, I've just removed the pointless self-assignment, with no
functional change.
2019-05-05 10:25:01 +01:00
Simon Tatham f1fe0c7d8d openssh_new_read: fix misaimed null pointer check.
If the input key_wanted field were set to an out-of-range value, the
parent structure retkey would not become NULL as a whole: instead, its
field 'key' would never be set to a non-null pointer. So I was testing
the wrong pointer.

Fortunately, this couldn't have come up, because we don't actually
have any support yet for loading the nth key from an OpenSSH new-style
key file containing more than one. So key_wanted was always set to 0
by load_openssh_new_key(), which also checked that the file's key
count was exactly 1 (guarding against the possibility that even 0
might have been an out-of-range index).
2019-05-05 10:25:01 +01:00
Simon Tatham cddec53a40 pscp: robustness fix in backend cleanup.
Coverity points out that in (the misnamed) psftp_main(), I allow for
the possibility that 'backend' might be null, up until the final
unconditional backend_free().

I haven't actually been able to find a way to make backend() come out
as NULL at all in that part of the code: obvious failure modes like
trying to scp to a nonexistent host trigger a connection_fatal() which
terminates the program without going through that code anyway. But I'm
not confident I tried everything, so I can't be sure there _isn't_ a
way to get NULL to that location, so let's put in the missing check
just in case.
2019-05-05 10:14:24 +01:00
Simon Tatham 0f6ce9bd01 Remove some spurious null pointer tests.
In load_openssh_new_key, ret->keyblob is never null any more: now that
it's a strbuf instead of a bare realloc()ed string, it's at worst an
_empty_ strbuf. Secondly, as Coverity pointed out, the null pointer
check was too late to do any good in the first place - the previous
clause of the same if condition would already have dereferenced it!

In test_mac in the auxiliary testsc program, there's no actual reason
I would ever have called it with null ssh_mac pointer - it would mean
'don't test anything'! Looks as if I just copy-pasted the MAC parts of
the cipher+MAC setup code in test_cipher.
2019-05-05 10:14:24 +01:00
Simon Tatham 64fdc85b2d Fix miscellaneous minor memory leaks.
All found by Coverity.
2019-05-05 10:14:24 +01:00
Simon Tatham e82ba498ff Fix broken error path on open failure in PROXY_FUZZ.
We have to use the file name we just failed to open to format an error
message _before_ freeing it, not after. If that use-after-free managed
not to cause a crash, we'd also leak the file descriptor 'outfd'.

Both spotted by Coverity (which is probably the first thing in years
to look seriously at any of the code designed for Ben's AFL exercise).
2019-05-05 08:39:15 +01:00
Simon Tatham c787e62651 fxp_fstat_recv: remove unreachable cleanup code.
Coverity pointed out a call to sftp_pkt_free(pktin) straight after an
unconditional return statement, which is obviously silly.

Fortunately, it was benign: pktin was freed anyway by the function
being called _by_ the return statement, so the unreachability of this
free operation prevented a double-free rather than allowing a memory
leak. So the right fix is to just remove the code, rather than
arranging for it to be run.
2019-05-05 08:38:45 +01:00
Simon Tatham 5f90427e0d Turn off hardware AES for the Coverity build.
It seems to have caused a compile error, apparently due to a mismatch
between compiler predefines (__SSE2__) and header files (emmintrin.h).
The easiest thing is to just turn off the hardware version completely,
so the rest of the code can still be scanned.
2019-05-05 08:38:37 +01:00
Simon Tatham fbd2c360fa Reinstate -DNO_SECUREZEROMEMORY for the Coverity build.
In commit 188e2525c I removed it from Winelib builds in general on the
grounds that Winelib had acquired that function. But now that I come
to try a Coverity build, I find that that is still one Winelib build
that does fail if I call SecureZeroMemory.
2019-05-04 14:48:40 +01:00
Simon Tatham 77aff29e18 Fix a benign buffer overrun in sshzlib.c.
The structure field 'lengths' in 'struct zlib_decompress_ctx' was the
right length for the amount of data you might _sensibly_ want to put
in it, but two bytes shorter than the amount that the compressed block
header allows someone to _physically_ try to put into it. Now it has
the full maximum length.

The previous overrun could only reach two bytes beyond the end of the
array, and in every target architecture I know of, those two bytes
would have been structure padding, so it wasn't causing any real trouble.
2019-04-28 10:02:23 +01:00
Simon Tatham eecefcb23c sshzlib: tighten up handling of invalid symbol codes.
In Deflate, both the literal/length and distance Huffman trees are
physically capable of encoding two symbol ids beyond the number that
the spec assigns any actual meaning to: a compressed block header can
specify code lengths for those two extra symbols if it wants to, in
which case those codes will be added to the Huffman tree (in
particular, will affect the encoding of everything else), but then
should not actually use those codes.

Our zlib decoder was silently ignoring the two invalid codes in the
literal/length tree, but treating the two invalid codes in the
distance tree as a fatal decoding error. That seems inconsistent. Now
we treat both as fatal decode errors.
2019-04-28 10:02:23 +01:00
Simon Tatham 1cd935e6c9 cryptsuite: add a test of rsa_verify.
This includes a regression test for the p=1 bug I just fixed, and also
adds some more basic tests just because it seemed silly not to.
2019-04-28 10:00:56 +01:00
Simon Tatham e9e800c773 testcrypt: allow ssh_key constructors to fail.
If key decoding or verification fails, those functions can return
NULL. Recognise that in the testcrypt API, so that I can test them.
2019-04-28 10:00:53 +01:00
Simon Tatham 4d0c2ca90f testcrypt: refactor return_opt_foo functions.
There are already three tediously similar functions that wrap a NULL
check around some existing function to return one or another kind of
pointer, and I'm about to want to add another one. Make a macro so
that it's easy to make more functions identical to these three.
2019-04-28 10:00:50 +01:00
Simon Tatham 4b8aad76f8 Fix assertion failure in rsa_verify.
If a malformed private key (received through any channel, whether
loaded from a disk file or over the wire by Pageant) specifies either
of the modulus's prime factors p or q as 1, then when rsa_verify tries
to check that e*d is congruent to 1 mod (p-1) and mod (q-1), that
check will involve a division by zero, which in this context means
failing an assertion in mp_divmod.

We were already doing a preliminary check that neither of p and q was
actually zero. Now that check is strengthened to check that p-1 and
q-1 are not zero either.
2019-04-28 10:00:46 +01:00
Simon Tatham 5f204d1ef1 kh2reg.py: handle OpenSSH hashed hostnames.
Obviously we can't do that by inverting the hash function itself, but
if the user provides one or more host names on the command line that
they're expecting to appear in the file, we can at least compare the
stored hashes against those.
2019-04-21 14:46:12 +01:00
Simon Tatham 0842d4627e kh2reg.py: add -o option to write output to a file.
Generally useful, I always think.
2019-04-21 14:46:12 +01:00
Simon Tatham ac1dd1bd2e kh2reg.py: switch from getopt to argparse.
This change gives us an automatic --help option, which is always
useful for a script used very rarely. It also makes it that much
easier to add extra options.
2019-04-21 14:46:12 +01:00
Simon Tatham 91333f7c74 kh2reg.py: refactor main program to bottom of file.
Now most of the program consists of function and class definitions,
and the code that activates it all is localised in one place at the
bottom instead of interleaved between the definitions.
2019-04-21 14:46:12 +01:00
Simon Tatham 33d4d223a5 kh2reg.py: work with Python 3. 2019-04-21 14:46:12 +01:00
Simon Tatham 5a508a84a2 kh2reg.py: support ECDSA point compression.
We support it in the ECC code proper these days, as of the bignum
rewrite in commit 25b034ee3. So we should support it in this auxiliary
script too, and fortunately, there's no real difficulty in doing so
because I already had some Python code kicking around in
test/eccref.py for taking modular square roots.
2019-04-21 14:46:12 +01:00
Jacob Nevins 81be535f67 Tweak __attribute__((format)) for MinGW.
This silences a bunch of spurious format warnings on a Ubuntu 14.04
mingw-w64 cross-compilation.
2019-04-21 13:02:40 +01:00
Jacob Nevins 134dc0bcaf Avoid using _vsnprintf on MinGW.
We went to the trouble of getting standard C99 format strings with
__USE_MINGW_ANSI_STDIO, but then used _vsnprintf, which bypasses them
and implements the non-standard Microsoft format strings, leading to
incorrect behaviour.
Ubuntu 14.04's mingw-w64 at least defines a vsnprintf() in all
circumstances, so we should use it.
2019-04-21 13:00:48 +01:00
Simon Tatham 65b3c93a8e Uppity: free the packet protocol layers on exit.
This bug and the one in the previous commit combined to mean that when
an SSH-1 connection through Uppity is terminated, the pty backend for
its main session channel was never cleaned up. (Firstly because
ssh1_connection_free never got called, and secondly because that in
turn forgot to free its mainchan.)

The effect of that in turn was that a _subsequent_ connection to the
same Uppity (using the new listening-socket mode) would likely reuse
the same fd for its pty, and the insertions into the ptyfds tree in
uxpty.c would silently fail because an existing Pty was already
occupying them, leading to a segfault when that Pty in turn responded
to events on a pty it didn't really own and tried to call back to a
seat that didn't exist any more.
2019-04-20 09:56:16 +01:00
Simon Tatham 07a43efb1f SSH-1: free mainchan_chan on destruction.
We went through the tree234 of ordinary channels freeing the thing at
the other end of each one, but of course in SSH-1 the main session
channel is not stored in that tree due to its totally different shape
in the protocol. So naturally I forgot to free _that_ one.
2019-04-20 09:56:16 +01:00
Simon Tatham 128d001c3e SSH-1: disable trust sigils after session starts.
This exactly replicates the way it's done in SSH-2: at the start of
the connection layer we set the trust status to untrusted, and if that
reports that it didn't give any indication to the user, we fall back
to presenting an interactive anti-spoofing prompt.

I don't know how I forgot to do that in SSH-1, and even more, how we
haven't noticed for a month. We noticed the same bug in _Rlogin_
within a day of the 0.71 release, after all!
2019-04-20 09:56:16 +01:00
Simon Tatham 98ed37f517 ssh2connection: missing free of antispoof_prompt.
Just noticed that if the session were to abort while that variable
contains some allocated data, it wouldn't be freed.
2019-04-20 09:56:16 +01:00
Simon Tatham f99aeb3129 mainchan.c: rewrite handling of open-failure aborts.
This is another case where a stale pointer bug could have arisen from
a toplevel callback going off after an object was freed.

But here, just adding delete_callbacks_for_context wouldn't help. The
actual context parameter for the callback wasn't mainchan itself; it
was a tiny separate object, allocated to hold just the parameters of
the function the callback wanted to call. So if _those_ parameters
became stale before the callback was triggered, then even
delete_callbacks_for_context wouldn't have been able to help.

Also, mainchan itself would have been freed moments after this
callback was queued, so moving it to be a callback on mainchan itself
wouldn't help.

Solution: move the callback right out to Ssh, by introducing a new
ssh_sw_abort_deferred() which is just like ssh_sw_abort but does its
main work in a toplevel callback. Then ssh.c's existing call to
delete_callbacks_for_context will clean it up if necessary.
2019-04-20 09:56:16 +01:00
Simon Tatham 108baae60e Add further missing delete_callbacks_for_context.
Having explicitly _stated_ in commit 4dcc0fddf the principle that if
you ever queue a toplevel callback on a freeable object then you
should also call delete_callbacks_for_context on that object before
freeing it, I realised I'd never actually gone through and checked
methodically at every call site of queue_toplevel_callback. So I did,
and naturally, I found several missing ones.
2019-04-20 08:29:23 +01:00
Simon Tatham 4dcc0fddf7 ssh2connection: clean up callbacks on exit.
We use a toplevel callback in the SSH-2 connection layer for checking
whether it's time to close the whole SSH session after a channel
closes. If the channel close itself, or something close enough to it,
involves a protocol error severe enough to abort the session and free
the connection layer, then that callback can fire anyway on stale
data.

The fix is the same as it always is in these situations: any object
which is ever used as the context parameter to queue_toplevel_callback
should also be passed to delete_callbacks_for_context before freeing it.
2019-04-20 08:02:52 +01:00
Jacob Nevins af01a6f07c UDP: the 'mac' directory no longer exists. 2019-04-19 16:11:23 +01:00
Jacob Nevins 2e50fbcc63 Docs: tweaks in Feedback for the modern world. 2019-04-19 16:11:23 +01:00
Jacob Nevins 05ab6304a2 FAQ: misc tweaks for the modern world. 2019-04-19 16:11:23 +01:00
Jacob Nevins 6e7d14ca9a Docs: list SSH specials before Telnet specials.
No textual change apart from the rearrangement.
2019-04-19 16:02:59 +01:00
Jacob Nevins ecbf919e77 Docs: tweak PuTTYgen "public keys for pasting".
Use the control name displayed for SSH-2 keys, since that's
overwhelmingly what people will care about these days.
2019-04-19 16:02:59 +01:00
Jacob Nevins 5aacd0d98e Docs: talk about SSH-2 before SSH-1.
Because SSH-1 is a very niche interest these days. Mostly this affects
the public key documentation.

Also, a couple of unrelated concessions to modernity.
2019-04-19 15:49:05 +01:00
Jacob Nevins 461844a5ec Docs: tweak other error messages for truth. 2019-04-19 15:49:05 +01:00
Jacob Nevins c86a56f49c Docs: correct some error messages.
In some messages, "server" became "remote" in 21a7ce7a07.
2019-04-19 15:49:05 +01:00
Jacob Nevins 8e6b1fd694 Docs: reorder Bugs/More bugs docs to match code.
The panels were rearranged in ab433e8073.
No textual change other than the rearrangement.
2019-04-19 15:49:05 +01:00
Jacob Nevins 6c9b1ffb2b Make docs match code for a couple of settings. 2019-04-19 15:49:05 +01:00