1
0
mirror of https://git.tartarus.org/simon/putty.git synced 2025-01-10 01:48:00 +00:00
Commit Graph

6802 Commits

Author SHA1 Message Date
Simon Tatham
bdab00341b Cancel drag-select when the context menu pops up.
I got a pterm into a stuck state this morning by an accidental mouse
action. I'd intended to press Ctrl + right-click to pop up the context
menu, but I accidentally pressed down the left button first, starting
a selection drag, and then while the left button was still held down,
pressed down the right button as well, triggering the menu.

The effect was that the context menu appeared while term->selstate was
set to DRAGGING, in which state terminal output is suppressed, and
which is only unset by a mouse-button release event. But then that
release event went to the popup menu, and the terminal window never
got it. So the terminal stayed stuck forever - or rather, until I
guessed the cause and did another selection drag to reset it.

This happened to me on GTK, but once I knew how I'd done it, I found I
could reproduce the same misbehaviour on Windows by the same method.
Added a simplistic fix, on both platforms, that cancels a selection
drag if the popup menu is summoned part way through it.
2022-03-29 18:06:14 +01:00
Simon Tatham
be16a7bbe3 testcrypt: remove a redundant typedef.
All the TD_consumed_foo types are defined by macro elsewhere in the
file, so there's no need for an explicit one for TD_consumed_val_hash.
2022-03-29 12:29:13 +01:00
Simon Tatham
a101444d40 New script to draw the icons as SVG.
This gets us scalable icons that will go to extremely large sizes
without the problems that arise from scaling up the output of
mkicon.py, in which outlines become too thin because the script was
mostly concerned with trying to squeeze all the desired detail into
_tiny_ sizes.

The SVG icons are generated by mksvg.py, which is a conversion of the
existing mkicon.py. So the SVG files themselves are not committed in
this repo; 'make svg' in the icons subdir will generate them.

(I haven't decided yet whether this state of affairs should be
permanent. Perhaps _having_ generated the SVGs via a similar program
to the bitmap icons, we should regard the script as a discardable
booster stage and redesignate the SVGs themselves as the source format
for future modifications, so that they can be edited in Inkscape or
similar rather than by tinkering with Python. On the other hand,
perhaps keeping the script will make it easier to keep the icon family
consistent, e.g. if changing the style of one of the shared visual
components.)

My plan is that we should stick with the output of the previous
bitmap-generating script for all the _small_ icons, up to and
including 48 pixels, because it does a better job at low resolution.
(That was really what it was for in the first place: you can think of
it as an analogue of a scalable-font hinting system, to tune the
scaling for very low res so that all the important features are still
visible.)

I think probably I want to switch the 128-pixel icons used in the Mac
icon file over to being rendered from the SVG (though in this commit I
haven't gone that far, not least because I'll also need to prepare a
corresponding black and white version). I haven't done extensive
research yet to decide where I think the crossover point in between
is.
2022-03-18 12:55:01 +00:00
Simon Tatham
5d58931b51 Fix trust status when Interactor returns a seat.
While testing the unrelated pile of commits just past, I accidentally
started a Cygwin saved session I hadn't run in ages which used the old
Telnet-based cygtermd as a local proxy command, and found that it
presented the Cygwin prompt with a trust sigil. Oops!

It turns out that this is because interactor_return_seat does two
things that can change the real seat's trust status, and it does them
in the wrong order: it defaults the status back to trusted (as if the
seat was brand new, because that's how they start out), and it calls
tempseat_flush which may have buffered a trust-status reset while the
seat was borrowed. The former should not override the latter!
2022-03-12 21:05:07 +00:00
Simon Tatham
f23a84cf7c windows/unicode.c: manually speak UTF-8.
This is another fallback needed on Win95, where the Win32 API
functions to convert between multibyte and wide strings exist, but
they haven't heard of the UTF-8 code page. PuTTY can't really do
without that these days.

(In particular, if a server sends a remote window-title escape
sequence while the terminal is in UTF-8 mode, then _something_ needs
to translate the UTF-8 data into Unicode for Windows to reconvert into
the character set used in window titles.)

This is a weird enough thing to be doing that I've put it under the
new #ifdef LEGACY_WINDOWS, so behaviour in the standard builds should
be unchanged.
2022-03-12 21:05:07 +00:00
Simon Tatham
3f76a86c13 Windows Pageant: deal with PeekMessageW failing on legacy Windows.
This makes Pageant run on Win95 again. Previously (after fixing the
startup-time failures due to missing security APIs) it would go into
an uninterruptible CPU-consuming spin in the message loop when every
attempt to retrieve its messages failed because PeekMessageW doesn't
work at all on the 95 series.
2022-03-12 21:05:07 +00:00
Simon Tatham
a2b376af96 Windows Pageant: turn 'has_security' into a global function.
Now it can be called from places other than Pageant's WinMain(). In
particular, the attempt to make a security descriptor in
lock_interprocess_mutex() is gated on it.

In return, however, I've tightened up the semantics. In normal PuTTY
builds that aren't trying to support pre-NT systems, the function
*unconditionally* returns true, on the grounds that we don't expect to
target any system that doesn't support the security APIs, and if
someone manages to contrive one anyway - or, more likely, if we some
day introduce a bug in our loading of the security API functions -
then this safety catch should make Pageant less likely to accidentally
fall back to 'never mind, just run in insecure mode'.
2022-03-12 21:05:07 +00:00
Simon Tatham
f500d24a95 Windows: runtime switch between Unicode and ANSI windows.
Turns out that PuTTY hasn't run successfully on legacy Windows since
0.66, in spite of an ongoing intention to keep it working. Among the
reasons for this is that CreateWindowExW simply fails with
ERROR_CALL_NOT_IMPLEMENTED: apparently Win95 and its ilk just didn't
have fully-Unicode windows as an option.

Fixed by resurrecting the previous code from the git history (in
particular, code removed by commit 67e5ceb9a8 was useful), and
including it as a runtime alternative.

One subtlety was that I found I had to name the A and W window classes
differently (by appending ".ansi" to the A one): apparently they
occupy the same namespace even though the names are in different
character sets, so if you somehow manage to register both classes,
they'll collide with each other without that tweak.
2022-03-12 21:05:07 +00:00
Simon Tatham
accf9adac2 Merge legacy-Windows fixes (mostly) from 'pre-0.77'. 2022-03-12 20:22:48 +00:00
Simon Tatham
01c007121a Remove hard dependencies on multi-monitor functions.
These are more functions that don't exist on all our supported legacy
versions of Windows, so we need to follow the same policy as
everywhere else, by trying to acquire them at run time and having a
fallback if they aren't available.
2022-03-12 18:51:21 +00:00
Simon Tatham
83ff08f9db Remove hard dependency on GetFileAttributesEx.
This fixes a load-time failure on versions of Windows too old to have
that function in kernel32.dll.

We use it to determine whether a file was safe to overwrite in the
context of PuTTY session logging: if it's safe, we skip the 'do you
want to overwrite or append?' dialog box.

On earlier Windows you can use FindFirstFile to get a similar effect,
so that's what we fall back to. It's not quite the same, though - if
you pass a wildcard then it will succeed when you'd rather it had
failed. But it's good enough to at least work in normal cases.
2022-03-12 18:51:21 +00:00
Simon Tatham
51f0057b67 Add a '#define LEGACY_WINDOWS'.
This will be used to wrap some of the stranger workarounds we're
keeping in this code base for the purposes of backwards compatibility
to seriously old platforms like Win95.
2022-03-12 18:51:21 +00:00
Simon Tatham
26dcfcbd44 Make init_winver() idempotent.
This way, anyone who needs to use the version data can quickly call
init_winver to make sure it's been set up, and not waste too much faff
redoing the actual work.
2022-03-12 18:51:21 +00:00
Simon Tatham
5de1df1b94 Windows: avoid idempotent window title changes.
By testing on a platform slow enough to show the flicker, I happened
to notice that if your shell prompt resets the window title every time
it's displayed, this was actually resulting in a call to SetWindowText
every time, which caused the GUI to actually do work.

There's certainly no need for that! We can at least avoid bothering if
the new title is identical to the old one.
2022-03-12 18:51:21 +00:00
Simon Tatham
901667280a Windows: initialise window_name and icon_name.
It turns out that they're still NULL at the first moment that a
SetWindowText call tries to read one of them, because they weren't
initialised at startup! Apparently SetWindowText notices that it's
been passed a null pointer, and does nothing in preference to failing,
but it's still not what I _meant_ to do.
2022-03-12 18:51:21 +00:00
Simon Tatham
fe00a2928c Windows: diagnose failure to create the terminal window.
It only fails in very unusual circumstances, but that's all the more
reason to give a useful report when it does!
2022-03-12 18:51:21 +00:00
Simon Tatham
cf41bc0c62 Unix mb_to_wc: add missing bounds checks.
Checking various implementations of these functions against each
other, I noticed by eyeball review that some of the special cases in
mb_to_wc() never check the buffer limit at all. Yikes!

Fortunately, I think there's no vulnerability, because these special
cases are ones that write out at most one wide char per multibyte
char, and at all the call sites (including dup_mb_to_wc) we allocate
that much even for the first attempt. The only exception to that is
the call in key_event() in unix/window.c, which uses a fixed-size
output buffer, but its input will always be the data generated by an X
keystroke event. So that one can only overrun the buffer if an X key
event manages to translate into more than 32 wide characters of text -
and even if that does come up in some exotic edge case, it will at
least not be happening under _enemy_ control.
2022-03-12 18:51:21 +00:00
Simon Tatham
b360ea6ac1 Add a manual single-char UTF-8 decoder.
This parallels encode_utf8 which we already had.

Decoding is more fraught with perils than encoding, so I've also
included a small test program.
2022-03-12 18:51:21 +00:00
Simon Tatham
21f602be40 Add utility function dup_wc_to_mb.
This parallels dup_mb_to_wc, which already existed. I haven't needed
the same thing this way round yet, but I'm about to.
2022-03-12 18:51:21 +00:00
Simon Tatham
269ea8aaf5 Move predeclaration of struct unicode_data into defs.h.
It's just the sort of thing that ought to be in there, once, so it
doesn't have to be declared in n places.
2022-03-12 18:51:21 +00:00
Simon Tatham
5243a2395a Merge pterm process-exit fix from 'pre-0.77'. 2022-03-08 18:06:13 +00:00
Simon Tatham
ee987ce4cd pterm.exe: fix handling of Windows exception codes.
Unlike on Unix, a Windows process's exit status is a DWORD, i.e. a
32-bit unsigned integer. And exit statuses seen in practice can range
up into the high half of that space. For example, if a process dies of
an 'illegal instruction' exception, then the exit status retrieved by
GetExitCodeProcess will be 0xC000001D == STATUS_ILLEGAL_INSTRUCTION.

If this happens to the process running inside pterm.exe, then
conpty->exitstatus will be set to a value greater than INT_MAX, which
will cause conpty_exitcode to return -1. Unfortunately, a -1 return
from conpty_exitstatus is treated by front ends as saying that the
backend process hasn't exited yet, and is still running. So pterm will
sit around after its subprocess has already terminated, contrary to
your 'close on exit' setting.

Moreover, when cmd.exe exits, it apparently passes on to its parent
process the exit status of the last subcommand it ran. So if you run a
Windows pterm containing an ordinary interactive console session, and
the last subprogram you happen to run inside that session dies of a
fatal signal, then the same thing will happen after you type 'exit' at
the command prompt.

This has been happening to me intermittently ever since I created
pterm.exe in the first place, and I guessed completely wrong about the
cause (I feared some kind of subtle race condition in pterm's use of
the process API). I've only just managed to reproduce it reliably
enough to debug, and I'm relieved to find it's much simpler than that!

The immediate fix, in any case, is to ensure we don't return -1 from
conpty_exitcode unless the process really is still running. And don't
return INT_MAX either, because that indicates 'unclean exit' in a way
that triggers 'close window only on clean exit' (and even Unix pterm
doesn't consider the primary subprocess dying of a signal to count as
unclean). So we clip all out-of-range Windows exception codes to
INT_MAX-1.

In the longer term I think it would be nice to turn exit codes into a
full 32-bit space, and move the special values completely out of it.
That would permit actually keeping the exact exception code and
passing it on to a caller who needed it. For example, if we were to
write a Windows psusan (which I could imagine being occasionally
useful), this way it would be able to return the unmodified full
Windows exit code via the "exit-status" chanreq. But I don't think we
currently have any clients needing that much detail, so that's a more
intrusive cleanup for a later date.
2022-03-08 18:05:48 +00:00
Simon Tatham
d73a6d6f06 Merge GSSAPI/DNS docs addition from 'pre-0.77'. 2022-02-22 18:45:51 +00:00
Simon Tatham
0613ec9986 Add a docs note about DNS performed by GSSAPI.
I recently noticed a mysterious delay at connection startup while
using an SSH jump host, and investigated it in case it was a bug in
the new jump host code that ought to be fixed before 0.77 goes out.

strace showed that at the time of the delay PuTTY was doing a DNS
lookup for the destination host, which was hanging due to the
authoritative DNS server in question not being reachable. But that was
odd, because I'd configured it to leave DNS lookup to the proxy,
anticipating exactly that problem.

But on closer investigation, the _proxy_ code was doing exactly what
I'd told it. The DNS lookup was coming from somewhere else: namely, an
(unsuccessful) attempt to set up a GSSAPI context. The GSSAPI library
had called gethostbyname, completely separately from PuTTY's own use
of DNS.

Simple workaround for me: turn off GSSAPI, which doesn't work for that
particular SSH connection anyway, and there's no point spending 30
seconds faffing just to find that out.

But also, if that puzzled me, it's worth documenting!
2022-02-22 18:44:48 +00:00
Simon Tatham
5886d610d8 Merge HTTP proxy fixes from 'pre-0.77'. 2022-02-19 12:53:51 +00:00
Simon Tatham
f85716be45 HTTP proxy: accept Digest algorithm name as a quoted string.
FreeProxy sends 'algorithm="MD5"' instead of 'algorithm=MD5.' I'm
actually not sure whether that's legal by RFC 7616, but it's certainly
no trouble to parse if we see it.

With all these changes, PuTTY now _can_ successfully make connections
through FreeProxy again, whether it's in Basic or Digest mode.
2022-02-19 12:51:59 +00:00
Simon Tatham
6c754822bc Proxy system: ability to reconnect to the proxy server.
Another awkward thing that FreeProxy does is to slam the connection
shut after sending its 407 response, at least in Basic auth mode. (It
keeps the connection alive in digest mode, which makes sense to me,
because that's a more stateful system.)

It was surprisingly easy to make the proxy code able to tolerate this!
I've set it up so that a ProxyNegotiator can just set its 'reconnect'
flag on return from the negotiation coroutine, and the effect will be
that proxy.c makes a new connection to the same proxy server before
doing anything else. In particular, you can set that flag _and_ put
data in the output bufchain, and there's no problem - the output data
will be queued directly into the new socket.
2022-02-19 12:51:59 +00:00
Simon Tatham
099d00c4ac HTTP proxy: accept the 'Proxy-Connection' header.
FreeProxy sends this as a substitute for the standard 'Connection'
header (with the same contents, i.e. 'keep-alive' or 'close' depending
on whether the TCP connection is going to continue afterwards). The
Internet reckons it's not standard, but it's easy to recognise as an
ad-hoc synonym for 'Connection'.
2022-02-19 12:51:50 +00:00
Simon Tatham
5c9a43f478 HTTP proxy: support 'Transfer-encoding: chunked'.
I had a report that the Windows free-as-in-beer proxy tool 'FreeProxy'
didn't work with the new HTTP proxy code, and it turns out that the
first reason why not is that the error-document in its 407 response is
sent via chunked transfer encoding, which is to say, instead of an
up-front Content-length header, you receive a sequence of chunks each
prefixed with a hex length.

(In 0.76, before the rewritten proxy support, we never even noticed
this because we sent Basic auth details up front in our first attempt,
rather than attempting a no-auth connection first and waiting to see
what kind of auth the proxy asks us for. So we'd only ever see a 407
if the auth details were refused - and since 0.76 didn't have
interactive proxy auth prompts, there was nothing we could do at that
point but abort immediately, without attempting to parse the rest of
the 407 at all.)

Now we spot the Transfer-encoding header and successfully parse
chunked transfers. Happily, we don't need to worry about the further
transfer-encodings such as 'gzip', because we're not actually _using_
the error document - we only have to skip over it to find the end of
the HTTP response.

This still doesn't make PuTTY work with FreeProxy, because there are
further problems hiding behind that one, which I'll fix in following
commits.
2022-02-19 12:50:51 +00:00
Simon Tatham
445f9de129 Fix handling of shifted SCO function keys.
A user points out that this has regressed since 0.76, probably when I
reorganised the keyboard control-sequence formatting into centralised
helper functions in terminal.c.

The SCO function keys should behave differently when you press Shift
or Ctrl or both. For example, F1 should generate ESC[M bare, ESC[Y
with Shift, Esc[k with Ctrl, Esc[w with Shift+Ctrl. But in fact, Shift
was having no effect, so those tests would give ESC[M twice and ESC[k
twice.

That was because I was setting 'shift = false' for all function key
types except FUNKY_XTERM_216, after modifying the derived 'index'
value. But the SCO branch of the code doesn't use 'index' (it wouldn't
have the right value in any case), so the sole effect was to forget
about Shift. Easily fixed by disabling that branch for FUNKY_SCO too.

(cherry picked from commit aa01530488)
2022-02-11 20:03:31 +00:00
Simon Tatham
aa01530488 Fix handling of shifted SCO function keys.
A user points out that this has regressed since 0.76, probably when I
reorganised the keyboard control-sequence formatting into centralised
helper functions in terminal.c.

The SCO function keys should behave differently when you press Shift
or Ctrl or both. For example, F1 should generate ESC[M bare, ESC[Y
with Shift, Esc[k with Ctrl, Esc[w with Shift+Ctrl. But in fact, Shift
was having no effect, so those tests would give ESC[M twice and ESC[k
twice.

That was because I was setting 'shift = false' for all function key
types except FUNKY_XTERM_216, after modifying the derived 'index'
value. But the SCO branch of the code doesn't use 'index' (it wouldn't
have the right value in any case), so the sole effect was to forget
about Shift. Easily fixed by disabling that branch for FUNKY_SCO too.
2022-02-10 18:51:19 +00:00
Simon Tatham
6f8db22972 Windows Pageant: option to open an AF_UNIX socket.
There's now a command-line option to make Pageant open an AF_UNIX
socket at a pathname of your choice. This allows it to act as an SSH
agent for any client program willing to use a WinSock AF_UNIX socket.

In particular, this allows WSL 1 processes to talk directly to Windows
Pageant without needing any intermediate process, because the AF_UNIX
sockets in the WSL 1 world interoperate with WinSock's ones.

(However, not WSL 2, which isn't very surprising.)
2022-02-05 12:58:41 +00:00
Simon Tatham
82971a3ebb Handle WM_NETEVENT in Windows Pageant.
Apparently when I made Windows Pageant use the winselgui system, I
added the call that gets WSAAsyncSelect response messages sent to
Pageant's window, but I didn't add the switch case in the window
procedure that actually handles those responses. I suppose I didn't
notice at the time because no actual functionality used it - Pageant
has never yet dealt with any real (i.e. Winsock) sockets, only with
HANDLE-based named pipes, which are called 'sockets' in PuTTY's
abstraction, but not by Windows.
2022-02-04 19:32:47 +00:00
Simon Tatham
018236da29 Support AF_UNIX listening sockets on Windows.
Not all Windows toolchains have this yet, so we have to put the
whole lot under #ifdef.
2022-02-04 19:32:47 +00:00
Simon Tatham
3d15342fe8 windows/network.c: refactor addr family in sk_newlistener.
Most of the previous large sk_newlistener function is now an inner
function whose address-family parameter is a platform AF_FOO constant
rather than one of our own ADDRTYPE_FOO. sk_newlistener itself is a
trivial wrapper on that, which just does the initial translation from
the input ADDRTYPE_FOO into an AF_FOO.

This will make it possible to drop in alternative wrapper functions
which won't have to make up a pointless ADDRTYPE.
2022-02-04 19:28:56 +00:00
Simon Tatham
04cc999b50 windows/network.c: refactor SOCKADDR_FAMILY.
This macro is now an inline function, and as in the previous commit,
each possible value for the main discriminator is now a case in a
switch statement instead of tested in an interlocking set of ?:.
2022-02-04 19:28:02 +00:00
Simon Tatham
5b5904b7cc windows/network.c: refactor switch in sk_newlistener.
The code that diverges based on the address family is now in the form
of a switch statement, rather than an unwieldy series of chained ifs.
And the final call to bind() has all its arguments worked out in the
previous switch, rather than computing them at the last minute with an
equally unwieldy set of ?: operators that repeat the previous test.

This will make it easier to add more cases, and also, to keep each
case under its own ifdef without losing too much legibility.
2022-02-04 19:26:25 +00:00
Simon Tatham
f08879a556 windows/network.c: create a 'superfamily' SockAddr field.
This replaces two previous boolean fields 'resolved' and 'namedpipe',
converting them into a single three-valued enum which avoids being
able to represent the meaningless fourth possibility at all. Also, it
provides an open-ended place to add further possibilities.

The new field is very similar to the one in unix/network.c, except
that the UNIX entry for AF_UNIX sockets is missing, and in its place
is the NAMEDPIPE entry for storing the pathnames of Windows named
pipes.
2022-02-04 19:25:35 +00:00
Simon Tatham
dd3d0e931f windows/network.c: reformat some mis-indented code.
Not quite sure how this all ended up a whole indent level off where it
should have been, but before I start modifying it, let's fix that.
2022-02-04 19:25:35 +00:00
Simon Tatham
72c492926f Merge GTK window size fixes from 'pre-0.77'. 2022-02-03 18:45:51 +00:00
Simon Tatham
9427f9699d GTK: fix junk in window margin with fixed-size windows.
When the window can't be resized for any reason, there will be extra
space inside the drawing area that's not part of our standard
width*font_width+2*window_border. We should include that in the
backing surface and make sure we erase it to the background colour,
otherwise it can end up containing unwanted visual junk.

An example is the same case described in the previous commit: maximise
the window and then start playing about with the font size. If you do
this while running a full-screen application that displays text in the
bottom line, it's easy to see that part of the previous display is
left over and not cleared when the new font size leaves more space at
the bottom than the old one.
2022-02-03 18:44:46 +00:00
Simon Tatham
1e98710174 GTK: fix font-size change when window maximised.
If you maximise the terminal window and then press Ctrl-> or Ctrl-< to
change the font size, then the maximised window can't change size, so
what _should_ happen instead is that the terminal adjusts the number
of character cells to whatever the new font size will now permit in
the same size of window as before.

But in fact, the terminal size wasn't changing at all, because the
call to gtkwin_request_resize (called from change_font_size) detected
the maximised window and went straight to gtkwin_deny_term_resize,
which immediately called term_size() to tell the terminal it still had
the same size as before.

This commit switches gtkwin_deny_term_resize so that instead it calls
drawing_area_setup_simple(), which re-runs drawing_area_setup with the
same size the drawing area already had. This should work out the same
in the case where we're _not_ changing the font size, but now also
does the right thing when we are.
2022-02-03 18:43:38 +00:00
Simon Tatham
1bfb1867ae Merge _MSC_VER translation updates from 'pre-0.77'. 2022-01-29 18:37:28 +00:00
Simon Tatham
397f3bd2b3 Add more _MSC_VER translations.
Visual Studio 2022 is out, and 2019 has added a couple more version
numbers while I wasn't looking.

Also, the main web page that lists the version number mappings now
documents the wrinkle where you sometimes have to disambiguate via
_MSC_FULL_VER (and indeed has added another such case for 16.11), so I
no longer have to link to some unofficial blog post in the comment
explaining that.

(*Also*, if _MSC_FULL_VER is worth checking, then it's worth putting
in the build info!)
2022-01-29 18:36:48 +00:00
Simon Tatham
39496e6fb4 Merge Coverity fixes from 'pre-0.77'. 2022-01-29 18:26:12 +00:00
Simon Tatham
b7a9cdd6ee term_get_userpass_input: missing NULL check.
If term_get_userpass_input is called with term->ldisc not yet set up,
then we had a special-case handler that returns an error message - but
it does it via the same subroutine that returns normal results, which
also turns off the prompt callback in term->ldisc! Need an extra NULL
check in that subroutine. Thanks Coverity.
2022-01-29 18:25:34 +00:00
Simon Tatham
d78d14f917 HTTP proxy: fix nonsense HTTP version check.
Substitution of && for || would have caused us to accept HTTP/1.0 when
we meant to reject it. Thanks Coverity!
2022-01-29 18:25:34 +00:00
Simon Tatham
6d77541080 bidi_test: minor memory fixes.
Spotted by Coverity: if you _just_ gave a filename to bidi_test,
without any previous argument that set testfn to something other than
NULL, the program would crash rather than giving an error message.

(It's only a test program, but test programs you only run once in a
blue moon are the ones that _most_ need to explain their command-line
syntax to you carefully, because you've forgotten it since last time
you used them!)

Also, conditionalised a memcpy on the size not being 0, because it's
illegal to pass a null pointer to memcpy _even_ if size==0. (That
would only happen with a test case containing a zero-length string,
but whatever.)
2022-01-29 18:25:34 +00:00
Simon Tatham
6344e40e3f cmdline.c: free cmdline_password whenever it's reset.
If you provided two -pw or -pwfile arguments on the same command line,
the first password could be left in memory uncleared. Spotted by
Coverity.
2022-01-29 18:25:34 +00:00
Simon Tatham
af6a19e962 sshproxy.c: add missing NULL check.
If you try to use a saved session for SSH proxying which specifies a
protocol that is not SSH or bare-SSH-connection, you get a clean error
return from the proxy setup code - *provided* it's at least a protocol
known to this particular build of PuTTY. If it's one so outlandish
that backend_vt_from_proto returns NULL, there'd have been a crash.

I don't think any such protocol currently exists, but if in the next
version of PuTTY some additional protocol becomes supported, it will
trip this error in the current version.

Spotted by Coverity.
2022-01-29 18:25:34 +00:00